Skip to content

Commit

Permalink
add common tags, update build.gradle
Browse files Browse the repository at this point in the history
  • Loading branch information
LemmaEOF committed Mar 27, 2019
1 parent 7c90f4a commit ef75336
Show file tree
Hide file tree
Showing 16 changed files with 238 additions and 15 deletions.
27 changes: 17 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ version = ext.version + ((ext.snapshot) ? "-SNAPSHOT" : "");

repositories {
mavenCentral()
maven {
url "http://server.bbkr.space:8081/artifactory/libs-snapshot"
}
}

dependencies {
Expand All @@ -75,8 +78,11 @@ dependencies {
if (project.ext.silkMod!=null) {
modCompile "io.github.prospector.silk:SilkAPI:"+project.ext.silkMod;
}
if (project.ext.cotton!=null) {
modCompile "io.github.cottonmc:cotton:"+project.ext.cotton
}
if (project.ext.jankson!=null) {
if (needsShadow) {
if (project.ext.needsShadow) {
//Jankson will be shadowed
shadow "blue.endless:jankson:"+project.ext.jankson;
implementation "blue.endless:jankson:"+project.ext.jankson;
Expand Down Expand Up @@ -138,16 +144,17 @@ publishing {
artifactNode.appendNode('version', it.moduleVersion)
}
}
def artifactEnding = (project.ext.needsShadow) ? "-shadow" : "";
artifacts = [
artifact ("${project.buildDir.absolutePath}/libs/${archivesBaseName}-${project.version}-shadow.jar") { //release jar - file location not provided anywhere in loom
classifier null
builtBy remapJar
},
artifact ("${project.buildDir.absolutePath}/libs/${archivesBaseName}-${project.version}-shadow-dev.jar") { //release jar - file location not provided anywhere in loom
classifier "dev"
builtBy remapJar
},
artifact (tasks.sourcesJar)
artifact ("${project.buildDir.absolutePath}/libs/${archivesBaseName}-${project.version}" + artifactEnding + ".jar") { //release jar - file location not provided anywhere in loom
classifier null
builtBy remapJar
},
artifact ("${project.buildDir.absolutePath}/libs/${archivesBaseName}-${project.version}" + artifactEnding + ".jar") { //release jar - file location not provided anywhere in loom
classifier "dev"
builtBy remapJar
},
artifact (tasks.sourcesJar)
]
}
}
Expand Down
3 changes: 2 additions & 1 deletion project.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ext {
projectName = "cotton";
group = "io.github.cottonmc";
version = "0.0.6+19w12b";
version = "0.0.7+19w12b";
snapshot = true;

minecraft = "19w12b";
Expand All @@ -10,6 +10,7 @@ ext {
fabricMod = "0.2.5.114";
silkMod = null;
jankson = "1.1.1"; //If needsShadow is false, jankson will not be included!
cotton = null;

needsShadow = true;
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/io/github/cottonmc/cotton/Cotton.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import io.github.cottonmc.cotton.config.ConfigManager;
import io.github.cottonmc.cotton.config.CottonConfig;
import io.github.cottonmc.cotton.datapack.loot.LootTableManager;
import io.github.cottonmc.cotton.logging.Ansi;
import io.github.cottonmc.cotton.logging.ModLogger;
import io.github.cottonmc.cotton.datapack.PackMetaManager;
import io.github.cottonmc.cotton.registry.CommonTags;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
import net.fabricmc.loader.api.FabricLoader;
Expand Down Expand Up @@ -39,6 +39,7 @@ public void onInitialize() {
config = ConfigManager.loadConfig(CottonConfig.class);
logger.info("Loaded config.");
PackMetaManager.saveMeta();
CommonTags.init();
//TagEntryManager.registerToTag(TagType.BLOCK, new Identifier("minecraft:enderman_holdable"), "minecraft:string");
//TagEntryManager.registerToTag(TagType.BLOCK, new Identifier("minecraft:dragon_immune"), "#minecraft:enderman_holdable");
//LootTableManager.registerBasicBlockDropTable(new Identifier("minecraft", "dirt"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ public class CottonConfig {
@Comment("A list of mod ids, in order of preference for resource loading.")
public List<String> namespace_preference_order = new ArrayList<>();

@Comment("Fill common tags automatically with modded items. This may add unintended items.\n"
+ "Intended for pack devs dealing with mods not using common tags.")
public boolean fillCommonTags = false;

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

public class PackMeta {
public int pack_format = 1;
public String description = "Cotton's auto-generated resource pack for adding tags.";
public String description = "Cotton's auto-generated resource pack.";
}
62 changes: 62 additions & 0 deletions src/main/java/io/github/cottonmc/cotton/registry/CommonTags.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package io.github.cottonmc.cotton.registry;

import io.github.cottonmc.cotton.Cotton;
import io.github.cottonmc.cotton.datapack.tags.TagEntryManager;
import io.github.cottonmc.cotton.datapack.tags.TagType;
import net.fabricmc.fabric.api.tag.TagRegistry;
import net.minecraft.item.Item;
import net.minecraft.item.block.BlockItem;
import net.minecraft.tag.Tag;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;

import java.util.ArrayList;
import java.util.List;


public class CommonTags {
//auto-fillable tags for common decorative/functional blocks
public static final Tag<Item> GLASS_BLOCKS = register("glass_blocks");
public static final Tag<Item> GLASS_PANES = register("glass_panes");
public static final Tag<Item> TERRACOTTA = register("terracotta");
public static final Tag<Item> CARPET = register("carpet");
public static final Tag<Item> PRESSURE_PLATES = register("pressure_plates");

//tags for common item categories
public static final Tag<Item> MUSHROOMS = register("mushrooms");
public static final Tag<Item> RAW_MEAT = register("raw_meat");
public static final Tag<Item> COOKED_MEAT = register("cooked_meat");

public static void init() {
if (Cotton.config.fillCommonTags) {
Cotton.logger.info("Generating common tags!");
List<String> glass_blocks = new ArrayList<>();
List<String> glass_panes = new ArrayList<>();
List<String> terracotta = new ArrayList<>();
List<String> carpets = new ArrayList<>();
List<String> pressure_plates = new ArrayList<>();

for (Identifier id : Registry.ITEM.getIds()) {
//vanilla entries are pre-loaded
if (id.getNamespace().equals("minecraft")) continue;
if (id.getPath().contains("glass") && Registry.ITEM.get(id) instanceof BlockItem) {
if (id.getPath().contains("pane")) glass_panes.add(id.toString());
else glass_blocks.add(id.toString());
}
if (id.getPath().contains("terracotta")) terracotta.add(id.toString());
if (id.getPath().contains("carpet")) carpets.add(id.toString());
if (id.getPath().contains("pressure_plate")) pressure_plates.add(id.toString());
}

if (!glass_blocks.isEmpty()) TagEntryManager.registerToTag(TagType.ITEM, GLASS_BLOCKS.getId(), glass_blocks.toArray(new String[0]));
if (!glass_panes.isEmpty()) TagEntryManager.registerToTag(TagType.ITEM, GLASS_PANES.getId(), glass_panes.toArray(new String[0]));
if (!terracotta.isEmpty()) TagEntryManager.registerToTag(TagType.ITEM, TERRACOTTA.getId(), terracotta.toArray(new String[0]));
if (!carpets.isEmpty()) TagEntryManager.registerToTag(TagType.ITEM, CARPET.getId(), carpets.toArray(new String[0]));
if (!pressure_plates.isEmpty()) TagEntryManager.registerToTag(TagType.ITEM, PRESSURE_PLATES.getId(), pressure_plates.toArray(new String[0]));
}
}

private static Tag<Item> register(String id) {
return TagRegistry.item(new Identifier(Cotton.SHARED_NAMESPACE, id));
}
}
2 changes: 1 addition & 1 deletion src/main/resources/assets/cotton/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"itemGroup.cotton:common_tab": "Common"
"itemGroup.cotton.common_tab": "Common"

}
21 changes: 21 additions & 0 deletions src/main/resources/data/c/tags/items/carpet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"replace": false,
"values": [
"minecraft:white_carpet",
"minecraft:orange_carpet",
"minecraft:magenta_carpet",
"minecraft:light_blue_carpet",
"minecraft:yellow_carpet",
"minecraft:lime_carpet",
"minecraft:pink_carpet",
"minecraft:gray_carpet",
"minecraft:light_gray_carpet",
"minecraft:cyan_carpet",
"minecraft:purple_carpet",
"minecraft:blue_carpet",
"minecraft:brown_carpet",
"minecraft:green_carpet",
"minecraft:red_carpet",
"minecraft:black_carpet"
]
}
12 changes: 12 additions & 0 deletions src/main/resources/data/c/tags/items/cooked_meat.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"replace": false,
"values": [
"minecraft:cooked_beef",
"minecraft:cooked_chicken",
"minecraft:cooked_cod",
"minecraft:cooked_mutton",
"minecraft:cooked_porkchop",
"minecraft:cooked_rabbit",
"minecraft:cooked_salmon"
]
}
22 changes: 22 additions & 0 deletions src/main/resources/data/c/tags/items/glass_blocks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"replace": false,
"values": [
"minecraft:glass",
"minecraft:white_stained_glass",
"minecraft:orange_stained_glass",
"minecraft:magenta_stained_glass",
"minecraft:light_blue_stained_glass",
"minecraft:yellow_stained_glass",
"minecraft:lime_stained_glass",
"minecraft:pink_stained_glass",
"minecraft:gray_stained_glass",
"minecraft:light_gray_stained_glass",
"minecraft:cyan_stained_glass",
"minecraft:purple_stained_glass",
"minecraft:blue_stained_glass",
"minecraft:brown_stained_glass",
"minecraft:green_stained_glass",
"minecraft:red_stained_glass",
"minecraft:black_stained_glass"
]
}
22 changes: 22 additions & 0 deletions src/main/resources/data/c/tags/items/glass_panes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"replace": false,
"values": [
"minecraft:glass_pane",
"minecraft:white_stained_glass_pane",
"minecraft:orange_stained_glass_pane",
"minecraft:magenta_stained_glass_pane",
"minecraft:light_blue_stained_glass_pane",
"minecraft:yellow_stained_glass_pane",
"minecraft:lime_stained_glass_pane",
"minecraft:pink_stained_glass_pane",
"minecraft:gray_stained_glass_pane",
"minecraft:light_gray_stained_glass_pane",
"minecraft:cyan_stained_glass_pane",
"minecraft:purple_stained_glass_pane",
"minecraft:blue_stained_glass_pane",
"minecraft:brown_stained_glass_pane",
"minecraft:green_stained_glass_pane",
"minecraft:red_stained_glass_pane",
"minecraft:black_stained_glass_pane"
]
}
7 changes: 7 additions & 0 deletions src/main/resources/data/c/tags/items/mushrooms.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"replace": false,
"values": [
"minecraft:brown_mushroom",
"minecraft:red_mushroom"
]
}
14 changes: 14 additions & 0 deletions src/main/resources/data/c/tags/items/pressure_plates.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"replace": false,
"values": [
"minecraft:stone_pressure_plate",
"minecraft:oak_pressure_plate",
"minecraft:spruce_pressure_plate",
"minecraft:birch_pressure_plate",
"minecraft:jungle_pressure_plate",
"minecraft:acacia_pressure_plate",
"minecraft:dark_oak_pressure_plate",
"minecraft:light_weighted_pressure_plate",
"minecraft:heavy_weighted_pressure_plate"
]
}
12 changes: 12 additions & 0 deletions src/main/resources/data/c/tags/items/raw_meat.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"replace": false,
"values": [
"minecraft:beef",
"minecraft:chicken",
"minecraft:cod",
"minecraft:mutton",
"minecraft:porkchop",
"minecraft:rabbit",
"minecraft:salmon"
]
}
38 changes: 38 additions & 0 deletions src/main/resources/data/c/tags/items/terracotta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"replace": false,
"values": [
"minecraft:white_terracotta",
"minecraft:orange_terracotta",
"minecraft:magenta_terracotta",
"minecraft:light_blue_terracotta",
"minecraft:yellow_terracotta",
"minecraft:lime_terracotta",
"minecraft:pink_terracotta",
"minecraft:gray_terracotta",
"minecraft:light_gray_terracotta",
"minecraft:cyan_terracotta",
"minecraft:purple_terracotta",
"minecraft:blue_terracotta",
"minecraft:brown_terracotta",
"minecraft:green_terracotta",
"minecraft:red_terracotta",
"minecraft:black_terracotta",
"minecraft:terracotta",
"minecraft:white_glazed_terracotta",
"minecraft:orange_glazed_terracotta",
"minecraft:magenta_glazed_terracotta",
"minecraft:light_blue_glazed_terracotta",
"minecraft:yellow_glazed_terracotta",
"minecraft:lime_glazed_terracotta",
"minecraft:pink_glazed_terracotta",
"minecraft:gray_glazed_terracotta",
"minecraft:light_gray_glazed_terracotta",
"minecraft:cyan_glazed_terracotta",
"minecraft:purple_glazed_terracotta",
"minecraft:blue_glazed_terracotta",
"minecraft:brown_glazed_terracotta",
"minecraft:green_glazed_terracotta",
"minecraft:red_glazed_terracotta",
"minecraft:black_glazed_terracotta"
]
}
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "cotton",
"name": "Cotton",
"version": "0.0.2",
"version": "0.0.7",
"side": "universal",
"initializers": [
"io.github.cottonmc.cotton.Cotton"
Expand Down

0 comments on commit ef75336

Please sign in to comment.