This commit is contained in:
Frank 2021-10-18 19:38:31 +02:00
parent a52b18ba9b
commit 073b473840
2 changed files with 387 additions and 361 deletions

View file

@ -1,7 +1,12 @@
package ru.bclib.api; package ru.bclib.api;
import java.util.Map;
import java.util.Set;
import java.util.function.Supplier;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import net.fabricmc.fabric.api.tag.TagRegistry; import net.fabricmc.fabric.api.tag.TagRegistry;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
@ -18,10 +23,6 @@ import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import ru.bclib.BCLib; import ru.bclib.BCLib;
import java.util.Map;
import java.util.Set;
import java.util.function.Supplier;
public class TagAPI { public class TagAPI {
private static final Map<ResourceLocation, Set<ResourceLocation>> TAGS_BLOCK = Maps.newConcurrentMap(); private static final Map<ResourceLocation, Set<ResourceLocation>> TAGS_BLOCK = Maps.newConcurrentMap();
private static final Map<ResourceLocation, Set<ResourceLocation>> TAGS_ITEM = Maps.newConcurrentMap(); private static final Map<ResourceLocation, Set<ResourceLocation>> TAGS_ITEM = Maps.newConcurrentMap();
@ -33,9 +34,14 @@ public class TagAPI {
public static final Tag.Named<Block> BLOCK_END_GROUND = makeBlockTag(BCLib.MOD_ID, "end_ground"); public static final Tag.Named<Block> BLOCK_END_GROUND = makeBlockTag(BCLib.MOD_ID, "end_ground");
public static final Tag.Named<Block> BLOCK_CHEST = makeCommonBlockTag("chest"); public static final Tag.Named<Block> BLOCK_CHEST = makeCommonBlockTag("chest");
public static final Tag.Named<Block> BLOCK_WOODEN_CHEST = makeCommonBlockTag("wooden_chests");
public static final Tag.Named<Block> BLOCK_BARREL = makeCommonBlockTag("barrel");
public static final Tag.Named<Block> BLOCK_WOODEN_BARREL = makeCommonBlockTag("wooden_barrels");
public static final Tag.Named<Block> BLOCK_END_STONES = makeCommonBlockTag("end_stones"); public static final Tag.Named<Block> BLOCK_END_STONES = makeCommonBlockTag("end_stones");
public static final Tag.Named<Block> BLOCK_NETHER_STONES = makeCommonBlockTag("nether_stones"); public static final Tag.Named<Block> BLOCK_NETHER_STONES = makeCommonBlockTag("nether_stones");
public static final Tag.Named<Block> BLOCK_WORKBENCHES = makeCommonBlockTag("workbenches"); public static final Tag.Named<Block> BLOCK_WORKBENCHES = makeCommonBlockTag("workbench");
public static final Tag.Named<Block> BLOCK_SAPLINGS = makeCommonBlockTag("saplings");
public static final Tag.Named<Block> BLOCK_LEAVES = makeCommonBlockTag("leaves");
public static final Tag.Named<Block> BLOCK_DRAGON_IMMUNE = getMCBlockTag("dragon_immune"); public static final Tag.Named<Block> BLOCK_DRAGON_IMMUNE = getMCBlockTag("dragon_immune");
@ -46,10 +52,16 @@ public class TagAPI {
// Item Tags // Item Tags
public static final Tag.Named<Item> ITEM_CHEST = makeCommonItemTag("chest"); public static final Tag.Named<Item> ITEM_CHEST = makeCommonItemTag("chest");
public static final Tag.Named<Item> ITEM_WOODEN_CHEST = makeCommonItemTag("wooden_chests");
public static final Tag.Named<Item> ITEM_BARREL = makeCommonItemTag("barrel");
public static final Tag.Named<Item> ITEM_WOODEN_BARREL = makeCommonItemTag("wooden_barrels");
public static final Tag.Named<Item> ITEM_IRON_INGOTS = makeCommonItemTag("iron_ingots"); public static final Tag.Named<Item> ITEM_IRON_INGOTS = makeCommonItemTag("iron_ingots");
public static final Tag.Named<Item> ITEM_FURNACES = makeCommonItemTag("furnaces"); public static final Tag.Named<Item> ITEM_FURNACES = makeCommonItemTag("furnaces");
public static final Tag.Named<Item> ITEM_WORKBENCHES = makeCommonItemTag("workbenches"); public static final Tag.Named<Item> ITEM_WORKBENCHES = makeCommonItemTag("workbench");
public final static Tag.Named<Item> ITEM_HAMMERS = makeCommonItemTag("hammers"); public final static Tag.Named<Item> ITEM_HAMMERS = makeCommonItemTag("hammers");
public static final Tag.Named<Item> ITEM_SAPLINGS = makeCommonItemTag("saplings");
public static final Tag.Named<Item> ITEM_LEAVES = makeCommonItemTag("leaves");
/** /**
* Get or create {@link Tag.Named}. * Get or create {@link Tag.Named}.

View file

@ -75,7 +75,8 @@ public class WoodenComplexMaterial extends ComplexMaterial {
@Override @Override
protected FabricBlockSettings getBlockSettings() { protected FabricBlockSettings getBlockSettings() {
return FabricBlockSettings.copyOf(Blocks.OAK_PLANKS).materialColor(planksColor); return FabricBlockSettings.copyOf(Blocks.OAK_PLANKS)
.materialColor(planksColor);
} }
@Override @Override
@ -131,32 +132,40 @@ public class WoodenComplexMaterial extends ComplexMaterial {
); );
addBlockEntry(new BlockEntry(BLOCK_PLANKS, (complexMaterial, settings) -> { addBlockEntry(new BlockEntry(BLOCK_PLANKS, (complexMaterial, settings) -> {
return new BaseBlock(settings); return new BaseBlock(settings);
}).setBlockTags(BlockTags.PLANKS).setItemTags(ItemTags.PLANKS)); }).setBlockTags(BlockTags.PLANKS)
.setItemTags(ItemTags.PLANKS));
addBlockEntry(new BlockEntry(BLOCK_STAIRS, (complexMaterial, settings) -> { addBlockEntry(new BlockEntry(BLOCK_STAIRS, (complexMaterial, settings) -> {
return new BaseStairsBlock(getBlock(BLOCK_PLANKS)); return new BaseStairsBlock(getBlock(BLOCK_PLANKS));
}).setBlockTags(BlockTags.WOODEN_STAIRS, BlockTags.STAIRS).setItemTags(ItemTags.WOODEN_STAIRS, ItemTags.STAIRS)); }).setBlockTags(BlockTags.WOODEN_STAIRS, BlockTags.STAIRS)
.setItemTags(ItemTags.WOODEN_STAIRS, ItemTags.STAIRS));
addBlockEntry(new BlockEntry(BLOCK_SLAB, (complexMaterial, settings) -> { addBlockEntry(new BlockEntry(BLOCK_SLAB, (complexMaterial, settings) -> {
return new BaseSlabBlock(getBlock(BLOCK_PLANKS)); return new BaseSlabBlock(getBlock(BLOCK_PLANKS));
}).setBlockTags(BlockTags.WOODEN_SLABS, BlockTags.SLABS).setItemTags(ItemTags.WOODEN_SLABS, ItemTags.SLABS)); }).setBlockTags(BlockTags.WOODEN_SLABS, BlockTags.SLABS)
.setItemTags(ItemTags.WOODEN_SLABS, ItemTags.SLABS));
addBlockEntry(new BlockEntry(BLOCK_FENCE, (complexMaterial, settings) -> { addBlockEntry(new BlockEntry(BLOCK_FENCE, (complexMaterial, settings) -> {
return new BaseFenceBlock(getBlock(BLOCK_PLANKS)); return new BaseFenceBlock(getBlock(BLOCK_PLANKS));
}).setBlockTags(BlockTags.FENCES, BlockTags.WOODEN_FENCES).setItemTags(ItemTags.FENCES, ItemTags.WOODEN_FENCES)); }).setBlockTags(BlockTags.FENCES, BlockTags.WOODEN_FENCES)
.setItemTags(ItemTags.FENCES, ItemTags.WOODEN_FENCES));
addBlockEntry(new BlockEntry(BLOCK_GATE, (complexMaterial, settings) -> { addBlockEntry(new BlockEntry(BLOCK_GATE, (complexMaterial, settings) -> {
return new BaseGateBlock(getBlock(BLOCK_PLANKS)); return new BaseGateBlock(getBlock(BLOCK_PLANKS));
}).setBlockTags(BlockTags.FENCE_GATES)); }).setBlockTags(BlockTags.FENCE_GATES));
addBlockEntry(new BlockEntry(BLOCK_BUTTON, (complexMaterial, settings) -> { addBlockEntry(new BlockEntry(BLOCK_BUTTON, (complexMaterial, settings) -> {
return new BaseWoodenButtonBlock(getBlock(BLOCK_PLANKS)); return new BaseWoodenButtonBlock(getBlock(BLOCK_PLANKS));
}).setBlockTags(BlockTags.BUTTONS, BlockTags.WOODEN_BUTTONS).setItemTags(ItemTags.BUTTONS, ItemTags.WOODEN_BUTTONS)); }).setBlockTags(BlockTags.BUTTONS, BlockTags.WOODEN_BUTTONS)
.setItemTags(ItemTags.BUTTONS, ItemTags.WOODEN_BUTTONS));
addBlockEntry(new BlockEntry(BLOCK_PRESSURE_PLATE, (complexMaterial, settings) -> { addBlockEntry(new BlockEntry(BLOCK_PRESSURE_PLATE, (complexMaterial, settings) -> {
return new WoodenPressurePlateBlock(getBlock(BLOCK_PLANKS)); return new WoodenPressurePlateBlock(getBlock(BLOCK_PLANKS));
}).setBlockTags(BlockTags.PRESSURE_PLATES, BlockTags.WOODEN_PRESSURE_PLATES).setItemTags(ItemTags.WOODEN_PRESSURE_PLATES)); }).setBlockTags(BlockTags.PRESSURE_PLATES, BlockTags.WOODEN_PRESSURE_PLATES)
.setItemTags(ItemTags.WOODEN_PRESSURE_PLATES));
addBlockEntry(new BlockEntry(BLOCK_TRAPDOOR, (complexMaterial, settings) -> { addBlockEntry(new BlockEntry(BLOCK_TRAPDOOR, (complexMaterial, settings) -> {
return new BaseTrapdoorBlock(getBlock(BLOCK_PLANKS)); return new BaseTrapdoorBlock(getBlock(BLOCK_PLANKS));
}).setBlockTags(BlockTags.TRAPDOORS, BlockTags.WOODEN_TRAPDOORS).setItemTags(ItemTags.TRAPDOORS, ItemTags.WOODEN_TRAPDOORS)); }).setBlockTags(BlockTags.TRAPDOORS, BlockTags.WOODEN_TRAPDOORS)
.setItemTags(ItemTags.TRAPDOORS, ItemTags.WOODEN_TRAPDOORS));
addBlockEntry(new BlockEntry(BLOCK_DOOR, (complexMaterial, settings) -> { addBlockEntry(new BlockEntry(BLOCK_DOOR, (complexMaterial, settings) -> {
return new BaseDoorBlock(getBlock(BLOCK_PLANKS)); return new BaseDoorBlock(getBlock(BLOCK_PLANKS));
}).setBlockTags(BlockTags.DOORS, BlockTags.WOODEN_DOORS).setItemTags(ItemTags.DOORS, ItemTags.WOODEN_DOORS)); }).setBlockTags(BlockTags.DOORS, BlockTags.WOODEN_DOORS)
.setItemTags(ItemTags.DOORS, ItemTags.WOODEN_DOORS));
addBlockEntry(new BlockEntry(BLOCK_LADDER, (complexMaterial, settings) -> { addBlockEntry(new BlockEntry(BLOCK_LADDER, (complexMaterial, settings) -> {
@ -164,24 +173,29 @@ public class WoodenComplexMaterial extends ComplexMaterial {
}).setBlockTags(BlockTags.CLIMBABLE)); }).setBlockTags(BlockTags.CLIMBABLE));
addBlockEntry(new BlockEntry(BLOCK_SIGN, (complexMaterial, settings) -> { addBlockEntry(new BlockEntry(BLOCK_SIGN, (complexMaterial, settings) -> {
return new BaseSignBlock(getBlock(BLOCK_PLANKS)); return new BaseSignBlock(getBlock(BLOCK_PLANKS));
}).setBlockTags(BlockTags.SIGNS).setItemTags(ItemTags.SIGNS)); }).setBlockTags(BlockTags.SIGNS)
.setItemTags(ItemTags.SIGNS));
} }
final protected void initStorage(FabricBlockSettings blockSettings, FabricItemSettings itemSettings){ final protected void initStorage(FabricBlockSettings blockSettings, FabricItemSettings itemSettings) {
addBlockEntry(new BlockEntry(BLOCK_CHEST, (complexMaterial, settings) -> { addBlockEntry(new BlockEntry(BLOCK_CHEST, (complexMaterial, settings) -> {
return new BaseChestBlock(getBlock(BLOCK_PLANKS)); return new BaseChestBlock(getBlock(BLOCK_PLANKS));
}).setBlockTags(TagAPI.BLOCK_CHEST).setItemTags(TagAPI.ITEM_CHEST)); }).setBlockTags(TagAPI.BLOCK_CHEST, TagAPI.BLOCK_WOODEN_CHEST)
.setItemTags(TagAPI.ITEM_CHEST, TagAPI.ITEM_WOODEN_CHEST));
addBlockEntry(new BlockEntry(BLOCK_BARREL, (complexMaterial, settings) -> { addBlockEntry(new BlockEntry(BLOCK_BARREL, (complexMaterial, settings) -> {
return new BaseBarrelBlock(getBlock(BLOCK_PLANKS)); return new BaseBarrelBlock(getBlock(BLOCK_PLANKS));
})); }).setBlockTags(TagAPI.BLOCK_BARREL, TagAPI.BLOCK_WOODEN_BARREL)
.setItemTags(TagAPI.ITEM_BARREL, TagAPI.ITEM_WOODEN_BARREL));
} }
final protected void initDecorations(FabricBlockSettings blockSettings, FabricItemSettings itemSettings){ final protected void initDecorations(FabricBlockSettings blockSettings, FabricItemSettings itemSettings) {
addBlockEntry(new BlockEntry(BLOCK_CRAFTING_TABLE, (complexMaterial, settings) -> { addBlockEntry(new BlockEntry(BLOCK_CRAFTING_TABLE, (complexMaterial, settings) -> {
return new BaseCraftingTableBlock(getBlock(BLOCK_PLANKS)); return new BaseCraftingTableBlock(getBlock(BLOCK_PLANKS));
}).setBlockTags(TagAPI.BLOCK_WORKBENCHES).setItemTags(TagAPI.ITEM_WORKBENCHES)); }).setBlockTags(TagAPI.BLOCK_WORKBENCHES)
.setItemTags(TagAPI.ITEM_WORKBENCHES));
addBlockEntry(new BlockEntry(BLOCK_BOOKSHELF, (complexMaterial, settings) -> { addBlockEntry(new BlockEntry(BLOCK_BOOKSHELF, (complexMaterial, settings) -> {
return new BaseBookshelfBlock(getBlock(BLOCK_PLANKS)); return new BaseBookshelfBlock(getBlock(BLOCK_PLANKS));
@ -217,7 +231,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
.setOutputCount(4) .setOutputCount(4)
.setList("#") .setList("#")
.addMaterial('#', log, bark, log_stripped, bark_stripped) .addMaterial('#', log, bark, log_stripped, bark_stripped)
.setGroup(receipGroupPrefix +"_planks") .setGroup(receipGroupPrefix + "_planks")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("stairs", (material, config, id) -> { addRecipeEntry(new RecipeEntry("stairs", (material, config, id) -> {
@ -226,7 +240,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
.setOutputCount(4) .setOutputCount(4)
.setShape("# ", "## ", "###") .setShape("# ", "## ", "###")
.addMaterial('#', planks) .addMaterial('#', planks)
.setGroup(receipGroupPrefix +"_planks_stairs") .setGroup(receipGroupPrefix + "_planks_stairs")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("slab", (material, config, id) -> { addRecipeEntry(new RecipeEntry("slab", (material, config, id) -> {
@ -235,7 +249,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
.setOutputCount(6) .setOutputCount(6)
.setShape("###") .setShape("###")
.addMaterial('#', planks) .addMaterial('#', planks)
.setGroup(receipGroupPrefix +"_planks_slabs") .setGroup(receipGroupPrefix + "_planks_slabs")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("fence", (material, config, id) -> { addRecipeEntry(new RecipeEntry("fence", (material, config, id) -> {
@ -245,7 +259,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
.setShape("#I#", "#I#") .setShape("#I#", "#I#")
.addMaterial('#', planks) .addMaterial('#', planks)
.addMaterial('I', Items.STICK) .addMaterial('I', Items.STICK)
.setGroup(receipGroupPrefix +"_planks_fences") .setGroup(receipGroupPrefix + "_planks_fences")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("gate", (material, config, id) -> { addRecipeEntry(new RecipeEntry("gate", (material, config, id) -> {
@ -254,7 +268,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
.setShape("I#I", "I#I") .setShape("I#I", "I#I")
.addMaterial('#', planks) .addMaterial('#', planks)
.addMaterial('I', Items.STICK) .addMaterial('I', Items.STICK)
.setGroup(receipGroupPrefix +"_planks_gates") .setGroup(receipGroupPrefix + "_planks_gates")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("button", (material, config, id) -> { addRecipeEntry(new RecipeEntry("button", (material, config, id) -> {
@ -262,7 +276,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
.checkConfig(config) .checkConfig(config)
.setList("#") .setList("#")
.addMaterial('#', planks) .addMaterial('#', planks)
.setGroup(receipGroupPrefix +"_planks_buttons") .setGroup(receipGroupPrefix + "_planks_buttons")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("pressure_plate", (material, config, id) -> { addRecipeEntry(new RecipeEntry("pressure_plate", (material, config, id) -> {
@ -270,7 +284,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
.checkConfig(config) .checkConfig(config)
.setShape("##") .setShape("##")
.addMaterial('#', planks) .addMaterial('#', planks)
.setGroup(receipGroupPrefix +"_planks_plates") .setGroup(receipGroupPrefix + "_planks_plates")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("trapdoor", (material, config, id) -> { addRecipeEntry(new RecipeEntry("trapdoor", (material, config, id) -> {
@ -279,7 +293,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
.setOutputCount(2) .setOutputCount(2)
.setShape("###", "###") .setShape("###", "###")
.addMaterial('#', planks) .addMaterial('#', planks)
.setGroup(receipGroupPrefix +"_trapdoors") .setGroup(receipGroupPrefix + "_trapdoors")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("door", (material, config, id) -> { addRecipeEntry(new RecipeEntry("door", (material, config, id) -> {
@ -288,7 +302,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
.setOutputCount(3) .setOutputCount(3)
.setShape("##", "##", "##") .setShape("##", "##", "##")
.addMaterial('#', planks) .addMaterial('#', planks)
.setGroup(receipGroupPrefix +"_doors") .setGroup(receipGroupPrefix + "_doors")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("crafting_table", (material, config, id) -> { addRecipeEntry(new RecipeEntry("crafting_table", (material, config, id) -> {
@ -296,7 +310,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
.checkConfig(config) .checkConfig(config)
.setShape("##", "##") .setShape("##", "##")
.addMaterial('#', planks) .addMaterial('#', planks)
.setGroup(receipGroupPrefix +"_tables") .setGroup(receipGroupPrefix + "_tables")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("ladder", (material, config, id) -> { addRecipeEntry(new RecipeEntry("ladder", (material, config, id) -> {
@ -306,7 +320,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
.setShape("I I", "I#I", "I I") .setShape("I I", "I#I", "I I")
.addMaterial('#', planks) .addMaterial('#', planks)
.addMaterial('I', Items.STICK) .addMaterial('I', Items.STICK)
.setGroup(receipGroupPrefix +"_ladders") .setGroup(receipGroupPrefix + "_ladders")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("sign", (material, config, id) -> { addRecipeEntry(new RecipeEntry("sign", (material, config, id) -> {
@ -316,7 +330,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
.setShape("###", "###", " I ") .setShape("###", "###", " I ")
.addMaterial('#', planks) .addMaterial('#', planks)
.addMaterial('I', Items.STICK) .addMaterial('I', Items.STICK)
.setGroup(receipGroupPrefix +"_signs") .setGroup(receipGroupPrefix + "_signs")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("chest", (material, config, id) -> { addRecipeEntry(new RecipeEntry("chest", (material, config, id) -> {
@ -324,7 +338,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
.checkConfig(config) .checkConfig(config)
.setShape("###", "# #", "###") .setShape("###", "# #", "###")
.addMaterial('#', planks) .addMaterial('#', planks)
.setGroup(receipGroupPrefix +"_chests") .setGroup(receipGroupPrefix + "_chests")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("barrel", (material, config, id) -> { addRecipeEntry(new RecipeEntry("barrel", (material, config, id) -> {
@ -333,7 +347,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
.setShape("#S#", "# #", "#S#") .setShape("#S#", "# #", "#S#")
.addMaterial('#', planks) .addMaterial('#', planks)
.addMaterial('S', getBlock(BLOCK_SLAB)) .addMaterial('S', getBlock(BLOCK_SLAB))
.setGroup(receipGroupPrefix +"_barrels") .setGroup(receipGroupPrefix + "_barrels")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("bookshelf", (material, config, id) -> { addRecipeEntry(new RecipeEntry("bookshelf", (material, config, id) -> {
@ -342,7 +356,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
.setShape("###", "PPP", "###") .setShape("###", "PPP", "###")
.addMaterial('#', planks) .addMaterial('#', planks)
.addMaterial('P', Items.BOOK) .addMaterial('P', Items.BOOK)
.setGroup(receipGroupPrefix +"_bookshelves") .setGroup(receipGroupPrefix + "_bookshelves")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("bark", (material, config, id) -> { addRecipeEntry(new RecipeEntry("bark", (material, config, id) -> {