From f9870d388e33f10dd3e8f040427dfb2a46d43b9a Mon Sep 17 00:00:00 2001 From: Frank Date: Sat, 20 May 2023 12:39:20 +0200 Subject: [PATCH] [Change] ComplexMaterials can use MaterialSlots now --- .../v2/advancement/AdvancementManager.java | 7 +- .../complexmaterials/ComplexMaterial.java | 93 ++++ .../complexmaterials/ComplexMaterialSet.java | 49 ++ .../WoodenComplexMaterial.java | 477 ++++-------------- .../complexmaterials/entry/MaterialSlot.java | 34 ++ .../entry/SimpleMaterialSlot.java | 68 +++ .../bclib/complexmaterials/set/wood/Bark.java | 62 +++ .../complexmaterials/set/wood/Barrel.java | 50 ++ .../bclib/complexmaterials/set/wood/Boat.java | 58 +++ .../complexmaterials/set/wood/Bookshelf.java | 49 ++ .../complexmaterials/set/wood/Button.java | 52 ++ .../complexmaterials/set/wood/Chest.java | 49 ++ .../complexmaterials/set/wood/ChestBoat.java | 64 +++ .../complexmaterials/set/wood/Composter.java | 46 ++ .../set/wood/CraftingTable.java | 49 ++ .../bclib/complexmaterials/set/wood/Door.java | 53 ++ .../complexmaterials/set/wood/Fence.java | 52 ++ .../bclib/complexmaterials/set/wood/Gate.java | 51 ++ .../complexmaterials/set/wood/Ladder.java | 50 ++ .../bclib/complexmaterials/set/wood/Log.java | 61 +++ .../complexmaterials/set/wood/Planks.java | 56 ++ .../set/wood/PressurePlate.java | 52 ++ .../bclib/complexmaterials/set/wood/Sign.java | 65 +++ .../bclib/complexmaterials/set/wood/Slab.java | 50 ++ .../complexmaterials/set/wood/Stairs.java | 50 ++ .../set/wood/StrippedBark.java | 58 +++ .../set/wood/StrippedLog.java | 57 +++ .../complexmaterials/set/wood/Trapdoor.java | 52 ++ .../complexmaterials/set/wood/WoodSlots.java | 32 ++ 29 files changed, 1554 insertions(+), 392 deletions(-) create mode 100644 src/main/java/org/betterx/bclib/complexmaterials/ComplexMaterialSet.java create mode 100644 src/main/java/org/betterx/bclib/complexmaterials/entry/MaterialSlot.java create mode 100644 src/main/java/org/betterx/bclib/complexmaterials/entry/SimpleMaterialSlot.java create mode 100644 src/main/java/org/betterx/bclib/complexmaterials/set/wood/Bark.java create mode 100644 src/main/java/org/betterx/bclib/complexmaterials/set/wood/Barrel.java create mode 100644 src/main/java/org/betterx/bclib/complexmaterials/set/wood/Boat.java create mode 100644 src/main/java/org/betterx/bclib/complexmaterials/set/wood/Bookshelf.java create mode 100644 src/main/java/org/betterx/bclib/complexmaterials/set/wood/Button.java create mode 100644 src/main/java/org/betterx/bclib/complexmaterials/set/wood/Chest.java create mode 100644 src/main/java/org/betterx/bclib/complexmaterials/set/wood/ChestBoat.java create mode 100644 src/main/java/org/betterx/bclib/complexmaterials/set/wood/Composter.java create mode 100644 src/main/java/org/betterx/bclib/complexmaterials/set/wood/CraftingTable.java create mode 100644 src/main/java/org/betterx/bclib/complexmaterials/set/wood/Door.java create mode 100644 src/main/java/org/betterx/bclib/complexmaterials/set/wood/Fence.java create mode 100644 src/main/java/org/betterx/bclib/complexmaterials/set/wood/Gate.java create mode 100644 src/main/java/org/betterx/bclib/complexmaterials/set/wood/Ladder.java create mode 100644 src/main/java/org/betterx/bclib/complexmaterials/set/wood/Log.java create mode 100644 src/main/java/org/betterx/bclib/complexmaterials/set/wood/Planks.java create mode 100644 src/main/java/org/betterx/bclib/complexmaterials/set/wood/PressurePlate.java create mode 100644 src/main/java/org/betterx/bclib/complexmaterials/set/wood/Sign.java create mode 100644 src/main/java/org/betterx/bclib/complexmaterials/set/wood/Slab.java create mode 100644 src/main/java/org/betterx/bclib/complexmaterials/set/wood/Stairs.java create mode 100644 src/main/java/org/betterx/bclib/complexmaterials/set/wood/StrippedBark.java create mode 100644 src/main/java/org/betterx/bclib/complexmaterials/set/wood/StrippedLog.java create mode 100644 src/main/java/org/betterx/bclib/complexmaterials/set/wood/Trapdoor.java create mode 100644 src/main/java/org/betterx/bclib/complexmaterials/set/wood/WoodSlots.java diff --git a/src/main/java/org/betterx/bclib/api/v2/advancement/AdvancementManager.java b/src/main/java/org/betterx/bclib/api/v2/advancement/AdvancementManager.java index 086a8407..d4ca94bb 100644 --- a/src/main/java/org/betterx/bclib/api/v2/advancement/AdvancementManager.java +++ b/src/main/java/org/betterx/bclib/api/v2/advancement/AdvancementManager.java @@ -3,6 +3,7 @@ package org.betterx.bclib.api.v2.advancement; import org.betterx.bclib.BCLib; import org.betterx.bclib.api.v2.levelgen.structures.BCLStructure; import org.betterx.bclib.complexmaterials.WoodenComplexMaterial; +import org.betterx.bclib.complexmaterials.set.wood.WoodSlots; import org.betterx.bclib.items.complex.EquipmentSet; import net.minecraft.advancements.*; @@ -379,9 +380,9 @@ public class AdvancementManager { public Builder addWoodCriterion(WoodenComplexMaterial mat) { return addInventoryChangedAnyCriterion( "got_" + mat.getBaseName(), - mat.getBlock(WoodenComplexMaterial.BLOCK_LOG), - mat.getBlock(WoodenComplexMaterial.BLOCK_BARK), - mat.getBlock(WoodenComplexMaterial.BLOCK_PLANKS) + mat.getBlock(WoodSlots.LOG), + mat.getBlock(WoodSlots.BARK), + mat.getBlock(WoodSlots.PLANKS) ); } diff --git a/src/main/java/org/betterx/bclib/complexmaterials/ComplexMaterial.java b/src/main/java/org/betterx/bclib/complexmaterials/ComplexMaterial.java index d2da96cb..6848cddc 100644 --- a/src/main/java/org/betterx/bclib/complexmaterials/ComplexMaterial.java +++ b/src/main/java/org/betterx/bclib/complexmaterials/ComplexMaterial.java @@ -2,6 +2,7 @@ package org.betterx.bclib.complexmaterials; import org.betterx.bclib.complexmaterials.entry.BlockEntry; import org.betterx.bclib.complexmaterials.entry.ItemEntry; +import org.betterx.bclib.complexmaterials.entry.MaterialSlot; import org.betterx.bclib.complexmaterials.entry.RecipeEntry; import org.betterx.bclib.registry.BlockRegistry; import org.betterx.bclib.registry.ItemRegistry; @@ -21,6 +22,7 @@ import com.google.common.collect.Maps; import java.util.Collection; import java.util.List; import java.util.Map; +import java.util.function.Consumer; import org.jetbrains.annotations.Nullable; public abstract class ComplexMaterial { @@ -162,6 +164,51 @@ public abstract class ComplexMaterial { return blocks.get(key); } + /** + * Get initiated {@link Block} from this {@link ComplexMaterial}. + * + * @param key {@link String} block name suffix (example: "mod:custom_log" will have a "log" suffix if "custom" is a base name of this material) + * @param runIfPresent {@link Consumer} to run if block is present. + * @return {@link Block} or {@code null} if nothing is stored. + */ + @Nullable + public Block ifBlockPresent(String key, Consumer runIfPresent) { + final Block block = blocks.get(key); + if (block != null) { + runIfPresent.accept(block); + } + return block; + } + + /** + * Get initiated {@link Block} from this {@link ComplexMaterial}. + * + * @param slot {@link MaterialSlot} The Block Entry + * @param runIfPresent {@link Consumer} to run if block is present. + * @param The {@link ComplexMaterial} this slot is usable for Type + * @return {@link Block} or {@code null} if nothing is stored. + */ + @Nullable + public Block ifBlockPresent(MaterialSlot slot, Consumer runIfPresent) { + final Block block = blocks.get(slot.suffix); + if (block != null) { + runIfPresent.accept(block); + } + return block; + } + + /** + * Get initiated {@link Block} from this {@link ComplexMaterial}. + * + * @param key {@link MaterialSlot} The Block Entry + * @param The {@link ComplexMaterial} this slot is usable for Type + * @return {@link Block} or {@code null} if nothing is stored. + */ + @Nullable + public Block getBlock(MaterialSlot key) { + return blocks.get(key.suffix); + } + /** * Get initiated {@link Item} from this {@link ComplexMaterial}. * @@ -173,6 +220,52 @@ public abstract class ComplexMaterial { return items.get(key); } + /** + * Get initiated {@link Item} from this {@link ComplexMaterial}. + * + * @param slot {@link MaterialSlot} The Item Entry + * @param The {@link ComplexMaterial} this slot is usable for Type + * @return {@link Item} or {@code null} if nothing is stored. + */ + @Nullable + public Item getItem(MaterialSlot slot) { + return items.get(slot.suffix); + } + + /** + * Get initiated {@link Item} from this {@link ComplexMaterial}. + * + * @param key {@link String} item name suffix (example: "mod:custom_apple" will have a "apple" suffix if "custom" is a base name of this material) + * @param runIfPresent {@link Consumer} to run if item is present. + * @return {@link Item} or {@code null} if nothing is stored. + */ + @Nullable + public Item ifItemPresent(String key, Consumer runIfPresent) { + final Item item = items.get(key); + if (item != null) { + runIfPresent.accept(item); + } + return item; + } + + /** + * Get initiated {@link Item} from this {@link ComplexMaterial}. + * + * @param slot {@link MaterialSlot} The Item Entry + * @param runIfPresent {@link Consumer} to run if item is present. + * @param The {@link ComplexMaterial} this slot is usable for Type + * @return {@link Item} or {@code null} if nothing is stored. + */ + @Nullable + public Item ifItemPresent(MaterialSlot slot, Consumer runIfPresent) { + final Item item = items.get(slot.suffix); + if (item != null) { + runIfPresent.accept(item); + } + return item; + } + + /** * Get default block settings for this material. * diff --git a/src/main/java/org/betterx/bclib/complexmaterials/ComplexMaterialSet.java b/src/main/java/org/betterx/bclib/complexmaterials/ComplexMaterialSet.java new file mode 100644 index 00000000..f6909756 --- /dev/null +++ b/src/main/java/org/betterx/bclib/complexmaterials/ComplexMaterialSet.java @@ -0,0 +1,49 @@ +package org.betterx.bclib.complexmaterials; + +import org.betterx.bclib.complexmaterials.entry.MaterialSlot; + +import net.minecraft.world.item.Item; +import net.minecraft.world.level.block.state.BlockBehaviour; + +import java.util.List; + +public abstract class ComplexMaterialSet> extends ComplexMaterial { + List> slots; + + protected ComplexMaterialSet(String modID, String baseName, String receipGroupPrefix) { + super(modID, baseName, receipGroupPrefix); + } + + protected abstract List> createMaterialSlots(); + + + @Override + protected final void initDefault(BlockBehaviour.Properties blockSettings, Item.Properties itemSettings) { + this.slots = createMaterialSlots(); + + for (MaterialSlot slot : slots) { + slot.addBlockEntry((M) this, this::addBlockEntry); + } + for (MaterialSlot slot : slots) { + slot.addItemEntry((M) this, this::addItemEntry); + } + + this.initAdditional(blockSettings, itemSettings); + } + + protected void initAdditional(BlockBehaviour.Properties blockSettings, Item.Properties itemSettings) { + + } + + @Override + protected final void initDefaultRecipes() { + super.initDefaultRecipes(); + this.initAdditionalRecipes(); + } + + protected void initAdditionalRecipes() { + for (MaterialSlot slot : slots) { + slot.addRecipeEntry((M) this, this::addRecipeEntry); + } + } +} diff --git a/src/main/java/org/betterx/bclib/complexmaterials/WoodenComplexMaterial.java b/src/main/java/org/betterx/bclib/complexmaterials/WoodenComplexMaterial.java index c1d81433..f7d51f0c 100644 --- a/src/main/java/org/betterx/bclib/complexmaterials/WoodenComplexMaterial.java +++ b/src/main/java/org/betterx/bclib/complexmaterials/WoodenComplexMaterial.java @@ -1,59 +1,56 @@ package org.betterx.bclib.complexmaterials; import org.betterx.bclib.BCLib; -import org.betterx.bclib.blocks.*; -import org.betterx.bclib.complexmaterials.entry.BlockEntry; -import org.betterx.bclib.complexmaterials.entry.RecipeEntry; -import org.betterx.bclib.recipes.BCLRecipeBuilder; -import org.betterx.worlds.together.tag.v3.CommonBlockTags; -import org.betterx.worlds.together.tag.v3.CommonItemTags; -import org.betterx.worlds.together.tag.v3.CommonPoiTags; +import org.betterx.bclib.complexmaterials.entry.MaterialSlot; +import org.betterx.bclib.complexmaterials.set.wood.WoodSlots; +import org.betterx.bclib.items.boat.BoatTypeOverride; import org.betterx.worlds.together.tag.v3.TagManager; -import net.minecraft.data.recipes.RecipeCategory; import net.minecraft.resources.ResourceLocation; -import net.minecraft.tags.BlockTags; -import net.minecraft.tags.ItemTags; -import net.minecraft.tags.TagKey; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.Items; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.material.MapColor; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.registry.FlammableBlockRegistry; -public class WoodenComplexMaterial extends ComplexMaterial { +import java.util.List; +import java.util.function.Consumer; +import org.jetbrains.annotations.Nullable; + +public class WoodenComplexMaterial extends ComplexMaterialSet { public static final ResourceLocation MATERIAL_ID = BCLib.makeID("wooden_material"); - public static final String BLOCK_CRAFTING_TABLE = "crafting_table"; - public static final String BLOCK_STRIPPED_BARK = "stripped_bark"; - public static final String BLOCK_STRIPPED_LOG = "stripped_log"; - public static final String BLOCK_PRESSURE_PLATE = "plate"; - public static final String BLOCK_BOOKSHELF = "bookshelf"; - public static final String BLOCK_COMPOSTER = "composter"; - public static final String BLOCK_TRAPDOOR = "trapdoor"; - public static final String BLOCK_BARREL = "barrel"; - public static final String BLOCK_BUTTON = "button"; - public static final String BLOCK_LADDER = "ladder"; - public static final String BLOCK_PLANKS = "planks"; - public static final String BLOCK_STAIRS = "stairs"; - public static final String BLOCK_CHEST = "chest"; - public static final String BLOCK_FENCE = "fence"; - public static final String BLOCK_BARK = "bark"; - public static final String BLOCK_DOOR = "door"; - public static final String BLOCK_GATE = "gate"; - public static final String BLOCK_SIGN = "sign"; - public static final String BLOCK_WALL_SIGN = "wall_sign"; - public static final String BLOCK_SLAB = "slab"; - public static final String BLOCK_LOG = "log"; + public static final String BLOCK_CRAFTING_TABLE = WoodSlots.CRAFTING_TABLE.suffix; + public static final String BLOCK_STRIPPED_BARK = WoodSlots.STRIPPED_BARK.suffix; + public static final String BLOCK_STRIPPED_LOG = WoodSlots.STRIPPED_LOG.suffix; + public static final String BLOCK_PRESSURE_PLATE = WoodSlots.PRESSURE_PLATE.suffix; + public static final String BLOCK_BOOKSHELF = WoodSlots.BOOKSHELF.suffix; + public static final String BLOCK_COMPOSTER = WoodSlots.COMPOSTER.suffix; + public static final String BLOCK_TRAPDOOR = WoodSlots.TRAPDOOR.suffix; + public static final String BLOCK_BARREL = WoodSlots.BARREL.suffix; + public static final String BLOCK_BUTTON = WoodSlots.BUTTON.suffix; + public static final String BLOCK_LADDER = WoodSlots.LADDER.suffix; + public static final String BLOCK_PLANKS = WoodSlots.PLANKS.suffix; + public static final String BLOCK_STAIRS = WoodSlots.STAIRS.suffix; + public static final String BLOCK_CHEST = WoodSlots.CHEST.suffix; + public static final String BLOCK_FENCE = WoodSlots.FENCE.suffix; + public static final String BLOCK_BARK = WoodSlots.BARK.suffix; + public static final String BLOCK_DOOR = WoodSlots.DOOR.suffix; + public static final String BLOCK_GATE = WoodSlots.GATE.suffix; + public static final String BLOCK_SIGN = WoodSlots.SIGN.suffix; + public static final String BLOCK_WALL_SIGN = WoodSlots.WALL_SIGN; + public static final String BLOCK_SLAB = WoodSlots.SLAB.suffix; + public static final String BLOCK_LOG = WoodSlots.LOG.suffix; + public static final String ITEM_BOAT = WoodSlots.BOAT.suffix; + public static final String ITEM_CHEST_BOAT = WoodSlots.CHEST_BOAT.suffix; public static final String TAG_LOGS = "logs"; public final MapColor planksColor; public final MapColor woodColor; + @Nullable + private BoatTypeOverride boatType; public final BCLWoodTypeWrapper woodType; @@ -63,11 +60,23 @@ public class WoodenComplexMaterial extends ComplexMaterial { String receipGroupPrefix, MapColor woodColor, MapColor planksColor + ) { + this(modID, baseName, receipGroupPrefix, woodColor, planksColor, false); + } + + public WoodenComplexMaterial( + String modID, + String baseName, + String receipGroupPrefix, + MapColor woodColor, + MapColor planksColor, + boolean withBoats ) { super(modID, baseName, receipGroupPrefix); this.planksColor = planksColor; this.woodColor = woodColor; this.woodType = BCLWoodTypeWrapper.create(modID, baseName).setColor(planksColor).build(); + this.boatType = null; } @Override @@ -88,371 +97,61 @@ public class WoodenComplexMaterial extends ComplexMaterial { } @Override - protected void initDefault(BlockBehaviour.Properties blockSettings, Item.Properties itemSettings) { - initBase(blockSettings, itemSettings); - initStorage(blockSettings, itemSettings); - initDecorations(blockSettings, itemSettings); - } + protected List> createMaterialSlots() { - final protected void initBase(BlockBehaviour.Properties blockSettings, Item.Properties itemSettings) { - TagKey tagBlockLog = getBlockTag(TAG_LOGS); - TagKey tagItemLog = getItemTag(TAG_LOGS); - - addBlockEntry( - new BlockEntry(BLOCK_STRIPPED_LOG, (complexMaterial, settings) -> new BaseRotatedPillarBlock(settings)) - .setBlockTags(BlockTags.LOGS, BlockTags.LOGS_THAT_BURN, tagBlockLog) - .setItemTags(ItemTags.LOGS, ItemTags.LOGS_THAT_BURN, tagItemLog) - ); - addBlockEntry( - new BlockEntry(BLOCK_STRIPPED_BARK, (complexMaterial, settings) -> new BaseBarkBlock(settings)) - .setBlockTags(BlockTags.LOGS, BlockTags.LOGS_THAT_BURN, tagBlockLog) - .setItemTags(ItemTags.LOGS, ItemTags.LOGS_THAT_BURN, tagItemLog) + var list = List.of( + WoodSlots.STRIPPED_LOG, + WoodSlots.STRIPPED_BARK, + WoodSlots.LOG, + WoodSlots.BARK, + WoodSlots.PLANKS, + WoodSlots.STAIRS, + WoodSlots.SLAB, + WoodSlots.FENCE, + WoodSlots.GATE, + WoodSlots.BUTTON, + WoodSlots.PRESSURE_PLATE, + WoodSlots.TRAPDOOR, + WoodSlots.DOOR, + WoodSlots.LADDER, + WoodSlots.SIGN, + WoodSlots.CHEST, + WoodSlots.BARREL, + WoodSlots.CRAFTING_TABLE, + WoodSlots.BOOKSHELF, + WoodSlots.COMPOSTER, + WoodSlots.BOAT, + WoodSlots.CHEST_BOAT ); - addBlockEntry( - new BlockEntry( - BLOCK_LOG, - (complexMaterial, settings) -> new BaseStripableLogBlock( - woodColor, - getBlock(BLOCK_STRIPPED_LOG) - ) - ) - .setBlockTags(BlockTags.LOGS, BlockTags.LOGS_THAT_BURN, tagBlockLog) - .setItemTags(ItemTags.LOGS, ItemTags.LOGS_THAT_BURN, tagItemLog) - ); - addBlockEntry( - new BlockEntry( - BLOCK_BARK, - (complexMaterial, settings) -> new StripableBarkBlock( - woodColor, - getBlock(BLOCK_STRIPPED_BARK) - ) - ) - .setBlockTags(BlockTags.LOGS, BlockTags.LOGS_THAT_BURN, tagBlockLog) - .setItemTags(ItemTags.LOGS, ItemTags.LOGS_THAT_BURN, tagItemLog) - ); - addBlockEntry(new BlockEntry(BLOCK_PLANKS, (complexMaterial, settings) -> new BaseBlock(settings)) - .setBlockTags(BlockTags.PLANKS) - .setItemTags(ItemTags.PLANKS)); - - addBlockEntry(new BlockEntry( - BLOCK_STAIRS, - (complexMaterial, settings) -> new BaseStairsBlock(getBlock(BLOCK_PLANKS), false) - ) - .setBlockTags(BlockTags.WOODEN_STAIRS, BlockTags.STAIRS) - .setItemTags(ItemTags.WOODEN_STAIRS, ItemTags.STAIRS)); - - addBlockEntry(new BlockEntry( - BLOCK_SLAB, - (complexMaterial, settings) -> new BaseSlabBlock(getBlock(BLOCK_PLANKS), false) - ) - .setBlockTags(BlockTags.WOODEN_SLABS, BlockTags.SLABS) - .setItemTags(ItemTags.WOODEN_SLABS, ItemTags.SLABS)); - - addBlockEntry(new BlockEntry( - BLOCK_FENCE, - (complexMaterial, settings) -> new BaseFenceBlock(getBlock(BLOCK_PLANKS)) - ) - .setBlockTags(BlockTags.FENCES, BlockTags.WOODEN_FENCES) - .setItemTags(ItemTags.FENCES, ItemTags.WOODEN_FENCES)); - - addBlockEntry(new BlockEntry( - BLOCK_GATE, - (complexMaterial, settings) -> new BaseGateBlock(getBlock(BLOCK_PLANKS), this.woodType.type()) - ) - .setBlockTags(BlockTags.FENCE_GATES)); - - addBlockEntry(new BlockEntry( - BLOCK_BUTTON, - (complexMaterial, settings) -> new BaseWoodenButtonBlock( - getBlock(BLOCK_PLANKS), - this.woodType.setType() - ) - ) - .setBlockTags(BlockTags.BUTTONS, BlockTags.WOODEN_BUTTONS) - .setItemTags(ItemTags.BUTTONS, ItemTags.WOODEN_BUTTONS)); - - addBlockEntry(new BlockEntry( - BLOCK_PRESSURE_PLATE, - (complexMaterial, settings) -> new WoodenPressurePlateBlock( - getBlock(BLOCK_PLANKS), - this.woodType.setType() - ) - ) - .setBlockTags(BlockTags.PRESSURE_PLATES, BlockTags.WOODEN_PRESSURE_PLATES) - .setItemTags(ItemTags.WOODEN_PRESSURE_PLATES)); - - addBlockEntry(new BlockEntry( - BLOCK_TRAPDOOR, - (complexMaterial, settings) -> new BaseTrapdoorBlock(getBlock(BLOCK_PLANKS), this.woodType.setType()) - ) - .setBlockTags(BlockTags.TRAPDOORS, BlockTags.WOODEN_TRAPDOORS) - .setItemTags(ItemTags.TRAPDOORS, ItemTags.WOODEN_TRAPDOORS)); - - addBlockEntry(new BlockEntry( - BLOCK_DOOR, - (complexMaterial, settings) -> new BaseDoorBlock(getBlock(BLOCK_PLANKS), this.woodType.setType()) - ) - .setBlockTags(BlockTags.DOORS, BlockTags.WOODEN_DOORS) - .setItemTags(ItemTags.DOORS, ItemTags.WOODEN_DOORS)); - - addBlockEntry(new BlockEntry( - BLOCK_LADDER, - (complexMaterial, settings) -> new BaseLadderBlock(getBlock(BLOCK_PLANKS)) - ) - .setBlockTags(BlockTags.CLIMBABLE)); - - addBlockEntry(new BlockEntry( - BLOCK_SIGN, - (complexMaterial, settings) -> new BaseSignBlock(woodType) - ) - .setBlockTags(BlockTags.SIGNS) - .setItemTags(ItemTags.SIGNS)); - - addBlockEntry(new BlockEntry( - BLOCK_WALL_SIGN, - false, - (complexMaterial, settings) -> { - if (getBlock(BLOCK_SIGN) instanceof BaseSignBlock sign) { - return sign.wallSign; - } - return null; - } - ) - .setBlockTags(BlockTags.WALL_SIGNS)); - } - - final protected void initStorage(BlockBehaviour.Properties blockSettings, Item.Properties itemSettings) { - addBlockEntry(new BlockEntry( - BLOCK_CHEST, - (complexMaterial, settings) -> new BaseChestBlock(getBlock(BLOCK_PLANKS)) - ) - .setBlockTags(CommonBlockTags.CHEST, CommonBlockTags.WOODEN_CHEST) - .setItemTags(CommonItemTags.CHEST, CommonItemTags.WOODEN_CHEST)); - - addBlockEntry(new BlockEntry( - BLOCK_BARREL, - (complexMaterial, settings) -> new BaseBarrelBlock(getBlock(BLOCK_PLANKS)) - ) - .setBlockTags(CommonBlockTags.BARREL, CommonBlockTags.WOODEN_BARREL) - .setItemTags(CommonItemTags.BARREL, CommonItemTags.WOODEN_BARREL)); - } - - protected void initDecorations(BlockBehaviour.Properties blockSettings, Item.Properties itemSettings) { - addBlockEntry(new BlockEntry( - BLOCK_CRAFTING_TABLE, - (cmx, settings) -> new BaseCraftingTableBlock(getBlock(BLOCK_PLANKS)) - ) - .setBlockTags(CommonBlockTags.WORKBENCHES) - .setItemTags(CommonItemTags.WORKBENCHES) - ); - - addBlockEntry(new BlockEntry( - BLOCK_BOOKSHELF, - (cmx, settings) -> new BaseBookshelfBlock(getBlock(BLOCK_PLANKS)) - ) - .setBlockTags(CommonBlockTags.BOOKSHELVES)); - - addBlockEntry(new BlockEntry( - BLOCK_COMPOSTER, - (complexMaterial, settings) -> new BaseComposterBlock(getBlock(BLOCK_PLANKS)) - ) - .setBlockTags(CommonPoiTags.FARMER_WORKSTATION)); + return list; } @Override protected void initFlammable(FlammableBlockRegistry registry) { + final Consumer addFlammableHardWood = (Block block) -> registry.add(block, 5, 5); getBlocks().forEach(block -> { registry.add(block, 5, 20); }); - registry.add(getBlock(BLOCK_LOG), 5, 5); - registry.add(getBlock(BLOCK_BARK), 5, 5); - registry.add(getBlock(BLOCK_STRIPPED_LOG), 5, 5); - registry.add(getBlock(BLOCK_STRIPPED_BARK), 5, 5); + ifBlockPresent(WoodSlots.LOG, addFlammableHardWood); + ifBlockPresent(WoodSlots.BARK, addFlammableHardWood); + ifBlockPresent(WoodSlots.STRIPPED_LOG, addFlammableHardWood); + ifBlockPresent(WoodSlots.STRIPPED_BARK, addFlammableHardWood); + } + + + public void initBoatType() { + if (getBoatType() == null) { + boatType = BoatTypeOverride.create( + getModID(), + getBaseName(), + getBlock(WoodSlots.PLANKS) + ); + } } - @Override - public void initDefaultRecipes() { - Block planks = getBlock(BLOCK_PLANKS); - addRecipeEntry(new RecipeEntry("planks", (material, id) -> { - Block log_stripped = getBlock(BLOCK_STRIPPED_LOG); - Block bark_stripped = getBlock(BLOCK_STRIPPED_BARK); - Block log = getBlock(BLOCK_LOG); - Block bark = getBlock(BLOCK_BARK); - BCLRecipeBuilder.crafting(id, planks) - .setOutputCount(4) - .shapeless() - .addMaterial('#', log, bark, log_stripped, bark_stripped) - .setGroup("planks") - .setCategory(RecipeCategory.BUILDING_BLOCKS) - .build(); - })); - addRecipeEntry(new RecipeEntry("stairs", (material, id) -> { - BCLRecipeBuilder.crafting(id, getBlock(BLOCK_STAIRS)) - .setOutputCount(4) - .setShape("# ", "## ", "###") - .addMaterial('#', planks) - .setGroup("stairs") - .setCategory(RecipeCategory.BUILDING_BLOCKS) - .build(); - })); - addRecipeEntry(new RecipeEntry("slab", (material, id) -> { - BCLRecipeBuilder.crafting(id, getBlock(BLOCK_SLAB)) - .setOutputCount(6) - .setShape("###") - .addMaterial('#', planks) - .setGroup("slab") - .setCategory(RecipeCategory.BUILDING_BLOCKS) - .build(); - })); - addRecipeEntry(new RecipeEntry("fence", (material, id) -> { - BCLRecipeBuilder.crafting(id, getBlock(BLOCK_FENCE)) - .setOutputCount(3) - .setShape("#I#", "#I#") - .addMaterial('#', planks) - .addMaterial('I', Items.STICK) - .setGroup("fence") - .setCategory(RecipeCategory.DECORATIONS) - .build(); - })); - addRecipeEntry(new RecipeEntry("gate", (material, id) -> { - BCLRecipeBuilder.crafting(id, getBlock(BLOCK_GATE)) - .setShape("I#I", "I#I") - .addMaterial('#', planks) - .addMaterial('I', Items.STICK) - .setGroup("gate") - .setCategory(RecipeCategory.REDSTONE) - .build(); - })); - addRecipeEntry(new RecipeEntry("button", (material, id) -> { - BCLRecipeBuilder.crafting(id, getBlock(BLOCK_BUTTON)) - .shapeless() - .addMaterial('#', planks) - .setGroup("button") - .setCategory(RecipeCategory.REDSTONE) - .build(); - })); - addRecipeEntry(new RecipeEntry("pressure_plate", (material, id) -> { - BCLRecipeBuilder.crafting(id, getBlock(BLOCK_PRESSURE_PLATE)) - .setShape("##") - .addMaterial('#', planks) - .setGroup("pressure_plate") - .setCategory(RecipeCategory.REDSTONE) - .build(); - })); - addRecipeEntry(new RecipeEntry("trapdoor", (material, id) -> { - BCLRecipeBuilder.crafting(id, getBlock(BLOCK_TRAPDOOR)) - .setOutputCount(2) - .setShape("###", "###") - .addMaterial('#', planks) - .setGroup("trapdoor") - .setCategory(RecipeCategory.REDSTONE) - .build(); - })); - addRecipeEntry(new RecipeEntry("door", (material, id) -> { - BCLRecipeBuilder.crafting(id, getBlock(BLOCK_DOOR)) - .setOutputCount(3) - .setShape("##", "##", "##") - .addMaterial('#', planks) - .setGroup("door") - .setCategory(RecipeCategory.REDSTONE) - .build(); - })); - addRecipeEntry(new RecipeEntry("crafting_table", (material, id) -> { - BCLRecipeBuilder.crafting(id, getBlock(BLOCK_CRAFTING_TABLE)) - .setShape("##", "##") - .addMaterial('#', planks) - .setGroup("table") - .setCategory(RecipeCategory.DECORATIONS) - .build(); - })); - addRecipeEntry(new RecipeEntry("ladder", (material, id) -> { - BCLRecipeBuilder.crafting(id, getBlock(BLOCK_LADDER)) - .setOutputCount(3) - .setShape("I I", "I#I", "I I") - .addMaterial('#', planks) - .addMaterial('I', Items.STICK) - .setGroup("ladder") - .setCategory(RecipeCategory.DECORATIONS) - .build(); - })); - addRecipeEntry(new RecipeEntry("sign", (material, id) -> { - BCLRecipeBuilder.crafting(id, getBlock(BLOCK_SIGN)) - .setOutputCount(3) - .setShape("###", "###", " I ") - .addMaterial('#', planks) - .addMaterial('I', Items.STICK) - .setGroup("sign") - .setCategory(RecipeCategory.DECORATIONS) - .build(); - })); - addRecipeEntry(new RecipeEntry("chest", (material, id) -> { - BCLRecipeBuilder.crafting(id, getBlock(BLOCK_CHEST)) - .setShape("###", "# #", "###") - .addMaterial('#', planks) - .setGroup("chest") - .setCategory(RecipeCategory.DECORATIONS) - .build(); - })); - addRecipeEntry(new RecipeEntry("barrel", (material, id) -> { - BCLRecipeBuilder.crafting(id, getBlock(BLOCK_BARREL)) - .setShape("#S#", "# #", "#S#") - .addMaterial('#', planks) - .addMaterial('S', getBlock(BLOCK_SLAB)) - .setGroup("barrel") - .setCategory(RecipeCategory.DECORATIONS) - .build(); - })); - addRecipeEntry(new RecipeEntry("bookshelf", (material, id) -> { - BCLRecipeBuilder.crafting(id, getBlock(BLOCK_BOOKSHELF)) - .setShape("###", "PPP", "###") - .addMaterial('#', planks) - .addMaterial('P', Items.BOOK) - .setGroup("bookshelf") - .setCategory(RecipeCategory.BUILDING_BLOCKS) - .build(); - })); - addRecipeEntry(new RecipeEntry("bark", (material, id) -> { - BCLRecipeBuilder.crafting(id, getBlock(BLOCK_BARK)) - .setShape("##", "##") - .addMaterial('#', getBlock(BLOCK_LOG)) - .setOutputCount(3) - .setCategory(RecipeCategory.BUILDING_BLOCKS) - .build(); - })); - addRecipeEntry(new RecipeEntry("log", (material, id) -> { - BCLRecipeBuilder.crafting(id, getBlock(BLOCK_LOG)) - .setShape("##", "##") - .addMaterial('#', getBlock(BLOCK_BARK)) - .setOutputCount(3) - .setCategory(RecipeCategory.BUILDING_BLOCKS) - .build(); - })); - addRecipeEntry(new RecipeEntry("stripped_bark", (material, id) -> { - BCLRecipeBuilder.crafting(id, getBlock(BLOCK_STRIPPED_BARK)) - .setShape("##", "##") - .addMaterial('#', getBlock(BLOCK_STRIPPED_LOG)) - .setOutputCount(3) - .setCategory(RecipeCategory.BUILDING_BLOCKS) - .build(); - })); - addRecipeEntry(new RecipeEntry("stripped_log", (material, id) -> { - BCLRecipeBuilder.crafting(id, getBlock(BLOCK_STRIPPED_LOG)) - .setShape("##", "##") - .addMaterial('#', getBlock(BLOCK_STRIPPED_BARK)) - .setOutputCount(3) - .setCategory(RecipeCategory.BUILDING_BLOCKS) - .build(); - })); - addRecipeEntry(new RecipeEntry("composter", (material, id) -> { - BCLRecipeBuilder.crafting(id, getBlock(BLOCK_COMPOSTER)) - .setShape("# #", "# #", "###") - .addMaterial('#', getBlock(BLOCK_SLAB)) - .setGroup("composter") - .setCategory(RecipeCategory.DECORATIONS) - .build(); - })); + public BoatTypeOverride getBoatType() { + return boatType; } - } \ No newline at end of file diff --git a/src/main/java/org/betterx/bclib/complexmaterials/entry/MaterialSlot.java b/src/main/java/org/betterx/bclib/complexmaterials/entry/MaterialSlot.java new file mode 100644 index 00000000..b311d036 --- /dev/null +++ b/src/main/java/org/betterx/bclib/complexmaterials/entry/MaterialSlot.java @@ -0,0 +1,34 @@ +package org.betterx.bclib.complexmaterials.entry; + +import org.betterx.bclib.complexmaterials.ComplexMaterial; + +import java.util.function.Consumer; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public abstract class MaterialSlot { + @NotNull + public final String suffix; + + public MaterialSlot(@NotNull String suffix) { + this.suffix = suffix; + } + + public abstract void addBlockEntry(M parentMaterial, Consumer adder); + public abstract void addRecipeEntry(M parentMaterial, Consumer adder); + + public void addItemEntry(M parentMaterial, Consumer adder) { + ItemEntry item = getItemEntry(parentMaterial); + if (item != null) { + adder.accept(item); + } + } + + @Nullable + protected ItemEntry getItemEntry(M parentMaterial) { + return null; + } + + public void onInit(M parentMaterial) { + } +} diff --git a/src/main/java/org/betterx/bclib/complexmaterials/entry/SimpleMaterialSlot.java b/src/main/java/org/betterx/bclib/complexmaterials/entry/SimpleMaterialSlot.java new file mode 100644 index 00000000..b464f3b7 --- /dev/null +++ b/src/main/java/org/betterx/bclib/complexmaterials/entry/SimpleMaterialSlot.java @@ -0,0 +1,68 @@ +package org.betterx.bclib.complexmaterials.entry; + +import org.betterx.bclib.complexmaterials.ComplexMaterial; + +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockBehaviour; + +import java.util.Objects; +import java.util.function.BiFunction; +import java.util.function.Consumer; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public abstract class SimpleMaterialSlot extends MaterialSlot { + public SimpleMaterialSlot(@NotNull String suffix) { + super(suffix); + } + + @Override + public void addBlockEntry(M parentMaterial, Consumer adder) { + adder.accept(getBlockEntry(parentMaterial)); + } + + @Nullable + protected BlockEntry getBlockEntry(M parentMaterial) { + var supplier = getBlockSupplier(parentMaterial); + if (supplier != null) { + final BlockEntry entry = new BlockEntry(suffix, supplier); + modifyBlockEntry(parentMaterial, entry); + return entry; + } + return null; + } + + protected void modifyBlockEntry(M parentMaterial, @NotNull BlockEntry entry) { + } + + @Override + public void addRecipeEntry(M parentMaterial, Consumer adder) { + adder.accept(getRecipeEntry(parentMaterial)); + } + + @NotNull + protected abstract BiFunction getBlockSupplier(M parentMaterial); + + protected @Nullable RecipeEntry getRecipeEntry(M parentMaterial) { + return new RecipeEntry(suffix, this::getRecipeSupplier); + } + + protected abstract @Nullable void getRecipeSupplier( + ComplexMaterial parentMaterial, + ResourceLocation id + ); + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof SimpleMaterialSlot)) return false; + SimpleMaterialSlot that = (SimpleMaterialSlot) o; + return suffix.equals(that.suffix); + } + + @Override + public int hashCode() { + return Objects.hash(suffix); + } +} diff --git a/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Bark.java b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Bark.java new file mode 100644 index 00000000..98b8c647 --- /dev/null +++ b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Bark.java @@ -0,0 +1,62 @@ +package org.betterx.bclib.complexmaterials.set.wood; + +import org.betterx.bclib.blocks.StripableBarkBlock; +import org.betterx.bclib.complexmaterials.ComplexMaterial; +import org.betterx.bclib.complexmaterials.WoodenComplexMaterial; +import org.betterx.bclib.complexmaterials.entry.BlockEntry; +import org.betterx.bclib.complexmaterials.entry.SimpleMaterialSlot; +import org.betterx.bclib.recipes.BCLRecipeBuilder; + +import net.minecraft.data.recipes.RecipeCategory; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.BlockTags; +import net.minecraft.tags.ItemTags; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockBehaviour; + +import java.util.function.BiFunction; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class Bark extends SimpleMaterialSlot { + public Bark() { + super("bark"); + } + + @Override + protected @NotNull BiFunction getBlockSupplier( + WoodenComplexMaterial parentMaterial + ) { + return (complexMaterial, settings) -> new StripableBarkBlock( + parentMaterial.woodColor, + complexMaterial.getBlock(WoodSlots.STRIPPED_BARK) + ); + } + + + @Override + protected void modifyBlockEntry(WoodenComplexMaterial parentMaterial, @NotNull BlockEntry entry) { + entry + .setBlockTags( + BlockTags.LOGS, + BlockTags.LOGS_THAT_BURN, + parentMaterial.getBlockTag(WoodenComplexMaterial.TAG_LOGS) + ) + .setItemTags( + ItemTags.LOGS, + ItemTags.LOGS_THAT_BURN, + parentMaterial.getItemTag(WoodenComplexMaterial.TAG_LOGS) + ); + } + + @Override + protected @Nullable void getRecipeSupplier(ComplexMaterial material, ResourceLocation id) { + BCLRecipeBuilder + .crafting(id, material.getBlock(suffix)) + .setShape("##", "##") + .addMaterial('#', material.getBlock(WoodSlots.LOG)) + .setOutputCount(3) + .setCategory(RecipeCategory.BUILDING_BLOCKS) + .build(); + } +} diff --git a/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Barrel.java b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Barrel.java new file mode 100644 index 00000000..e48c7958 --- /dev/null +++ b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Barrel.java @@ -0,0 +1,50 @@ +package org.betterx.bclib.complexmaterials.set.wood; + +import org.betterx.bclib.blocks.BaseBarrelBlock; +import org.betterx.bclib.complexmaterials.ComplexMaterial; +import org.betterx.bclib.complexmaterials.WoodenComplexMaterial; +import org.betterx.bclib.complexmaterials.entry.BlockEntry; +import org.betterx.bclib.complexmaterials.entry.SimpleMaterialSlot; +import org.betterx.bclib.recipes.BCLRecipeBuilder; +import org.betterx.worlds.together.tag.v3.CommonBlockTags; +import org.betterx.worlds.together.tag.v3.CommonItemTags; + +import net.minecraft.data.recipes.RecipeCategory; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockBehaviour; + +import java.util.function.BiFunction; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class Barrel extends SimpleMaterialSlot { + public Barrel() { + super("barrel"); + } + + @Override + protected @NotNull BiFunction getBlockSupplier( + WoodenComplexMaterial parentMaterial + ) { + return (complexMaterial, settings) -> new BaseBarrelBlock(complexMaterial.getBlock(WoodSlots.PLANKS)); + } + + @Override + protected void modifyBlockEntry(WoodenComplexMaterial parentMaterial, @NotNull BlockEntry entry) { + entry.setBlockTags(CommonBlockTags.BARREL, CommonBlockTags.WOODEN_BARREL) + .setItemTags(CommonItemTags.BARREL, CommonItemTags.WOODEN_BARREL); + } + + @Override + protected @Nullable void getRecipeSupplier(ComplexMaterial parentMaterial, ResourceLocation id) { + BCLRecipeBuilder + .crafting(id, parentMaterial.getBlock(suffix)) + .setShape("#S#", "# #", "#S#") + .addMaterial('#', parentMaterial.getBlock(WoodSlots.PLANKS)) + .addMaterial('S', parentMaterial.getBlock(WoodSlots.SLAB)) + .setGroup("barrel") + .setCategory(RecipeCategory.DECORATIONS) + .build(); + } +} diff --git a/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Boat.java b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Boat.java new file mode 100644 index 00000000..c11ff56d --- /dev/null +++ b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Boat.java @@ -0,0 +1,58 @@ +package org.betterx.bclib.complexmaterials.set.wood; + +import org.betterx.bclib.complexmaterials.ComplexMaterial; +import org.betterx.bclib.complexmaterials.WoodenComplexMaterial; +import org.betterx.bclib.complexmaterials.entry.BlockEntry; +import org.betterx.bclib.complexmaterials.entry.ItemEntry; +import org.betterx.bclib.complexmaterials.entry.SimpleMaterialSlot; +import org.betterx.bclib.recipes.BCLRecipeBuilder; + +import net.minecraft.data.recipes.RecipeCategory; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockBehaviour; + +import java.util.function.BiFunction; +import java.util.function.Consumer; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class Boat extends SimpleMaterialSlot { + public Boat() { + super("boat"); + } + + @Override + public void addBlockEntry(WoodenComplexMaterial parentMaterial, Consumer adder) { + } + + @Override + protected @NotNull BiFunction getBlockSupplier( + WoodenComplexMaterial parentMaterial + ) { + return (a, b) -> { + return null; + }; + } + + @Override + protected @Nullable ItemEntry getItemEntry(WoodenComplexMaterial parentMaterial) { + return new ItemEntry(suffix, (cmx, settings) -> parentMaterial.getBoatType().createItem(false)); + } + + @Override + protected @Nullable void getRecipeSupplier(ComplexMaterial parentMaterial, ResourceLocation id) { + BCLRecipeBuilder + .crafting(id, parentMaterial.getBlock(suffix)) + .setShape("# #", "###") + .addMaterial('#', parentMaterial.getBlock(WoodSlots.PLANKS)) + .setGroup("boat") + .setCategory(RecipeCategory.TRANSPORTATION) + .build(); + } + + @Override + public void onInit(WoodenComplexMaterial parentMaterial) { + parentMaterial.initBoatType(); + } +} diff --git a/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Bookshelf.java b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Bookshelf.java new file mode 100644 index 00000000..e8c6a703 --- /dev/null +++ b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Bookshelf.java @@ -0,0 +1,49 @@ +package org.betterx.bclib.complexmaterials.set.wood; + +import org.betterx.bclib.blocks.BaseBookshelfBlock; +import org.betterx.bclib.complexmaterials.ComplexMaterial; +import org.betterx.bclib.complexmaterials.WoodenComplexMaterial; +import org.betterx.bclib.complexmaterials.entry.BlockEntry; +import org.betterx.bclib.complexmaterials.entry.SimpleMaterialSlot; +import org.betterx.bclib.recipes.BCLRecipeBuilder; +import org.betterx.worlds.together.tag.v3.CommonBlockTags; + +import net.minecraft.data.recipes.RecipeCategory; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockBehaviour; + +import java.util.function.BiFunction; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class Bookshelf extends SimpleMaterialSlot { + public Bookshelf() { + super("bookshelf"); + } + + @Override + protected @NotNull BiFunction getBlockSupplier( + WoodenComplexMaterial parentMaterial + ) { + return (cmx, settings) -> new BaseBookshelfBlock(cmx.getBlock(WoodSlots.PLANKS)); + } + + @Override + protected void modifyBlockEntry(WoodenComplexMaterial parentMaterial, @NotNull BlockEntry entry) { + entry.setBlockTags(CommonBlockTags.BOOKSHELVES); + } + + @Override + protected @Nullable void getRecipeSupplier(ComplexMaterial parentMaterial, ResourceLocation id) { + BCLRecipeBuilder + .crafting(id, parentMaterial.getBlock(suffix)) + .setShape("###", "PPP", "###") + .addMaterial('#', parentMaterial.getBlock(WoodSlots.PLANKS)) + .addMaterial('P', Items.BOOK) + .setGroup("bookshelf") + .setCategory(RecipeCategory.BUILDING_BLOCKS) + .build(); + } +} diff --git a/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Button.java b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Button.java new file mode 100644 index 00000000..43a03532 --- /dev/null +++ b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Button.java @@ -0,0 +1,52 @@ +package org.betterx.bclib.complexmaterials.set.wood; + +import org.betterx.bclib.blocks.BaseWoodenButtonBlock; +import org.betterx.bclib.complexmaterials.ComplexMaterial; +import org.betterx.bclib.complexmaterials.WoodenComplexMaterial; +import org.betterx.bclib.complexmaterials.entry.BlockEntry; +import org.betterx.bclib.complexmaterials.entry.SimpleMaterialSlot; +import org.betterx.bclib.recipes.BCLRecipeBuilder; + +import net.minecraft.data.recipes.RecipeCategory; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.BlockTags; +import net.minecraft.tags.ItemTags; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockBehaviour; + +import java.util.function.BiFunction; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class Button extends SimpleMaterialSlot { + public Button() { + super("button"); + } + + @Override + protected @NotNull BiFunction getBlockSupplier( + WoodenComplexMaterial parentMaterial + ) { + return (complexMaterial, settings) -> new BaseWoodenButtonBlock( + complexMaterial.getBlock(WoodSlots.PLANKS), + parentMaterial.woodType.setType() + ); + } + + @Override + protected void modifyBlockEntry(WoodenComplexMaterial parentMaterial, @NotNull BlockEntry entry) { + entry.setBlockTags(BlockTags.BUTTONS, BlockTags.WOODEN_BUTTONS) + .setItemTags(ItemTags.BUTTONS, ItemTags.WOODEN_BUTTONS); + } + + @Override + protected @Nullable void getRecipeSupplier(ComplexMaterial parentMaterial, ResourceLocation id) { + BCLRecipeBuilder + .crafting(id, parentMaterial.getBlock(suffix)) + .shapeless() + .addMaterial('#', parentMaterial.getBlock(WoodSlots.PLANKS)) + .setGroup("button") + .setCategory(RecipeCategory.REDSTONE) + .build(); + } +} diff --git a/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Chest.java b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Chest.java new file mode 100644 index 00000000..195818bc --- /dev/null +++ b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Chest.java @@ -0,0 +1,49 @@ +package org.betterx.bclib.complexmaterials.set.wood; + +import org.betterx.bclib.blocks.BaseChestBlock; +import org.betterx.bclib.complexmaterials.ComplexMaterial; +import org.betterx.bclib.complexmaterials.WoodenComplexMaterial; +import org.betterx.bclib.complexmaterials.entry.BlockEntry; +import org.betterx.bclib.complexmaterials.entry.SimpleMaterialSlot; +import org.betterx.bclib.recipes.BCLRecipeBuilder; +import org.betterx.worlds.together.tag.v3.CommonBlockTags; +import org.betterx.worlds.together.tag.v3.CommonItemTags; + +import net.minecraft.data.recipes.RecipeCategory; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockBehaviour; + +import java.util.function.BiFunction; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class Chest extends SimpleMaterialSlot { + public Chest() { + super("chest"); + } + + @Override + protected @NotNull BiFunction getBlockSupplier( + WoodenComplexMaterial parentMaterial + ) { + return (complexMaterial, settings) -> new BaseChestBlock(complexMaterial.getBlock(WoodSlots.PLANKS)); + } + + @Override + protected void modifyBlockEntry(WoodenComplexMaterial parentMaterial, @NotNull BlockEntry entry) { + entry.setBlockTags(CommonBlockTags.CHEST, CommonBlockTags.WOODEN_CHEST) + .setItemTags(CommonItemTags.CHEST, CommonItemTags.WOODEN_CHEST); + } + + @Override + protected @Nullable void getRecipeSupplier(ComplexMaterial parentMaterial, ResourceLocation id) { + BCLRecipeBuilder + .crafting(id, parentMaterial.getBlock(suffix)) + .setShape("###", "# #", "###") + .addMaterial('#', parentMaterial.getBlock(WoodSlots.PLANKS)) + .setGroup("chest") + .setCategory(RecipeCategory.DECORATIONS) + .build(); + } +} diff --git a/src/main/java/org/betterx/bclib/complexmaterials/set/wood/ChestBoat.java b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/ChestBoat.java new file mode 100644 index 00000000..e039fd94 --- /dev/null +++ b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/ChestBoat.java @@ -0,0 +1,64 @@ +package org.betterx.bclib.complexmaterials.set.wood; + +import org.betterx.bclib.complexmaterials.ComplexMaterial; +import org.betterx.bclib.complexmaterials.WoodenComplexMaterial; +import org.betterx.bclib.complexmaterials.entry.BlockEntry; +import org.betterx.bclib.complexmaterials.entry.ItemEntry; +import org.betterx.bclib.complexmaterials.entry.SimpleMaterialSlot; +import org.betterx.bclib.recipes.BCLRecipeBuilder; +import org.betterx.worlds.together.tag.v3.CommonItemTags; + +import net.minecraft.data.recipes.RecipeCategory; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.ItemTags; +import net.minecraft.tags.TagKey; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockBehaviour; + +import java.util.function.BiFunction; +import java.util.function.Consumer; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class ChestBoat extends SimpleMaterialSlot { + public ChestBoat() { + super("chest_boat"); + } + + @Override + public void addBlockEntry(WoodenComplexMaterial parentMaterial, Consumer adder) { + } + + @Override + protected @NotNull BiFunction getBlockSupplier( + WoodenComplexMaterial parentMaterial + ) { + return (a, b) -> { + return null; + }; + } + + @Override + protected @Nullable ItemEntry getItemEntry(WoodenComplexMaterial parentMaterial) { + return new ItemEntry( + suffix, + (cmx, settings) -> parentMaterial.getBoatType().createItem(true) + ).setItemTags(new TagKey[]{ItemTags.CHEST_BOATS}); + } + + @Override + protected @Nullable void getRecipeSupplier(ComplexMaterial parentMaterial, ResourceLocation id) { + BCLRecipeBuilder.crafting(id, parentMaterial.getBlock(suffix)) + .shapeless() + .addMaterial('C', CommonItemTags.CHEST) + .addMaterial('#', parentMaterial.getBlock(WoodSlots.BOAT)) + .setGroup("chest_boat") + .setCategory(RecipeCategory.TRANSPORTATION) + .build(); + } + + @Override + public void onInit(WoodenComplexMaterial parentMaterial) { + parentMaterial.initBoatType(); + } +} diff --git a/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Composter.java b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Composter.java new file mode 100644 index 00000000..4c6225c1 --- /dev/null +++ b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Composter.java @@ -0,0 +1,46 @@ +package org.betterx.bclib.complexmaterials.set.wood; + +import org.betterx.bclib.blocks.BaseComposterBlock; +import org.betterx.bclib.complexmaterials.ComplexMaterial; +import org.betterx.bclib.complexmaterials.WoodenComplexMaterial; +import org.betterx.bclib.complexmaterials.entry.BlockEntry; +import org.betterx.bclib.complexmaterials.entry.SimpleMaterialSlot; +import org.betterx.bclib.recipes.BCLRecipeBuilder; +import org.betterx.worlds.together.tag.v3.CommonPoiTags; + +import net.minecraft.data.recipes.RecipeCategory; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockBehaviour; + +import java.util.function.BiFunction; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class Composter extends SimpleMaterialSlot { + public Composter() { + super("composter"); + } + + @Override + protected @NotNull BiFunction getBlockSupplier( + WoodenComplexMaterial parentMaterial + ) { + return (complexMaterial, settings) -> new BaseComposterBlock(complexMaterial.getBlock(WoodSlots.PLANKS)); + } + + @Override + protected void modifyBlockEntry(WoodenComplexMaterial parentMaterial, @NotNull BlockEntry entry) { + entry.setBlockTags(CommonPoiTags.FARMER_WORKSTATION); + } + + @Override + protected @Nullable void getRecipeSupplier(ComplexMaterial parentMaterial, ResourceLocation id) { + BCLRecipeBuilder.crafting(id, parentMaterial.getBlock(suffix)) + .setShape("# #", "# #", "###") + .addMaterial('#', parentMaterial.getBlock(WoodSlots.SLAB)) + .setGroup("composter") + .setCategory(RecipeCategory.DECORATIONS) + .build(); + } +} diff --git a/src/main/java/org/betterx/bclib/complexmaterials/set/wood/CraftingTable.java b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/CraftingTable.java new file mode 100644 index 00000000..6fbefd94 --- /dev/null +++ b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/CraftingTable.java @@ -0,0 +1,49 @@ +package org.betterx.bclib.complexmaterials.set.wood; + +import org.betterx.bclib.blocks.BaseCraftingTableBlock; +import org.betterx.bclib.complexmaterials.ComplexMaterial; +import org.betterx.bclib.complexmaterials.WoodenComplexMaterial; +import org.betterx.bclib.complexmaterials.entry.BlockEntry; +import org.betterx.bclib.complexmaterials.entry.SimpleMaterialSlot; +import org.betterx.bclib.recipes.BCLRecipeBuilder; +import org.betterx.worlds.together.tag.v3.CommonBlockTags; +import org.betterx.worlds.together.tag.v3.CommonItemTags; + +import net.minecraft.data.recipes.RecipeCategory; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockBehaviour; + +import java.util.function.BiFunction; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class CraftingTable extends SimpleMaterialSlot { + public CraftingTable() { + super("crafting_table"); + } + + @Override + protected @NotNull BiFunction getBlockSupplier( + WoodenComplexMaterial parentMaterial + ) { + return (cmx, settings) -> new BaseCraftingTableBlock(cmx.getBlock(WoodSlots.PLANKS)); + } + + @Override + protected void modifyBlockEntry(WoodenComplexMaterial parentMaterial, @NotNull BlockEntry entry) { + entry.setBlockTags(CommonBlockTags.WORKBENCHES) + .setItemTags(CommonItemTags.WORKBENCHES); + } + + @Override + protected @Nullable void getRecipeSupplier(ComplexMaterial parentMaterial, ResourceLocation id) { + BCLRecipeBuilder + .crafting(id, parentMaterial.getBlock(suffix)) + .setShape("##", "##") + .addMaterial('#', parentMaterial.getBlock(WoodSlots.PLANKS)) + .setGroup("table") + .setCategory(RecipeCategory.DECORATIONS) + .build(); + } +} diff --git a/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Door.java b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Door.java new file mode 100644 index 00000000..444ad585 --- /dev/null +++ b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Door.java @@ -0,0 +1,53 @@ +package org.betterx.bclib.complexmaterials.set.wood; + +import org.betterx.bclib.blocks.BaseDoorBlock; +import org.betterx.bclib.complexmaterials.ComplexMaterial; +import org.betterx.bclib.complexmaterials.WoodenComplexMaterial; +import org.betterx.bclib.complexmaterials.entry.BlockEntry; +import org.betterx.bclib.complexmaterials.entry.SimpleMaterialSlot; +import org.betterx.bclib.recipes.BCLRecipeBuilder; + +import net.minecraft.data.recipes.RecipeCategory; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.BlockTags; +import net.minecraft.tags.ItemTags; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockBehaviour; + +import java.util.function.BiFunction; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class Door extends SimpleMaterialSlot { + public Door() { + super("door"); + } + + @Override + protected @NotNull BiFunction getBlockSupplier( + WoodenComplexMaterial parentMaterial + ) { + return (complexMaterial, settings) -> new BaseDoorBlock( + complexMaterial.getBlock(WoodSlots.PLANKS), + parentMaterial.woodType.setType() + ); + } + + @Override + protected void modifyBlockEntry(WoodenComplexMaterial parentMaterial, @NotNull BlockEntry entry) { + entry.setBlockTags(BlockTags.DOORS, BlockTags.WOODEN_DOORS) + .setItemTags(ItemTags.DOORS, ItemTags.WOODEN_DOORS); + } + + @Override + protected @Nullable void getRecipeSupplier(ComplexMaterial parentMaterial, ResourceLocation id) { + BCLRecipeBuilder + .crafting(id, parentMaterial.getBlock(suffix)) + .setOutputCount(3) + .setShape("##", "##", "##") + .addMaterial('#', parentMaterial.getBlock(WoodSlots.PLANKS)) + .setGroup("door") + .setCategory(RecipeCategory.REDSTONE) + .build(); + } +} diff --git a/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Fence.java b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Fence.java new file mode 100644 index 00000000..1ce62d58 --- /dev/null +++ b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Fence.java @@ -0,0 +1,52 @@ +package org.betterx.bclib.complexmaterials.set.wood; + +import org.betterx.bclib.blocks.BaseFenceBlock; +import org.betterx.bclib.complexmaterials.ComplexMaterial; +import org.betterx.bclib.complexmaterials.WoodenComplexMaterial; +import org.betterx.bclib.complexmaterials.entry.BlockEntry; +import org.betterx.bclib.complexmaterials.entry.SimpleMaterialSlot; +import org.betterx.bclib.recipes.BCLRecipeBuilder; + +import net.minecraft.data.recipes.RecipeCategory; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.BlockTags; +import net.minecraft.tags.ItemTags; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockBehaviour; + +import java.util.function.BiFunction; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class Fence extends SimpleMaterialSlot { + public Fence() { + super("fence"); + } + + @Override + protected @NotNull BiFunction getBlockSupplier( + WoodenComplexMaterial parentMaterial + ) { + return (complexMaterial, settings) -> new BaseFenceBlock(complexMaterial.getBlock(WoodSlots.PLANKS)); + } + + @Override + protected void modifyBlockEntry(WoodenComplexMaterial parentMaterial, @NotNull BlockEntry entry) { + entry.setBlockTags(BlockTags.FENCES, BlockTags.WOODEN_FENCES) + .setItemTags(ItemTags.FENCES, ItemTags.WOODEN_FENCES); + } + + @Override + protected @Nullable void getRecipeSupplier(ComplexMaterial parentMaterial, ResourceLocation id) { + BCLRecipeBuilder + .crafting(id, parentMaterial.getBlock(suffix)) + .setOutputCount(3) + .setShape("#I#", "#I#") + .addMaterial('#', parentMaterial.getBlock(WoodSlots.PLANKS)) + .addMaterial('I', Items.STICK) + .setGroup("fence") + .setCategory(RecipeCategory.DECORATIONS) + .build(); + } +} diff --git a/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Gate.java b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Gate.java new file mode 100644 index 00000000..3ff9eb7a --- /dev/null +++ b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Gate.java @@ -0,0 +1,51 @@ +package org.betterx.bclib.complexmaterials.set.wood; + +import org.betterx.bclib.blocks.BaseGateBlock; +import org.betterx.bclib.complexmaterials.ComplexMaterial; +import org.betterx.bclib.complexmaterials.WoodenComplexMaterial; +import org.betterx.bclib.complexmaterials.entry.BlockEntry; +import org.betterx.bclib.complexmaterials.entry.SimpleMaterialSlot; +import org.betterx.bclib.recipes.BCLRecipeBuilder; + +import net.minecraft.data.recipes.RecipeCategory; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.BlockTags; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockBehaviour; + +import java.util.function.BiFunction; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class Gate extends SimpleMaterialSlot { + public Gate() { + super("gate"); + } + + @Override + protected @NotNull BiFunction getBlockSupplier( + WoodenComplexMaterial parentMaterial + ) { + return (complexMaterial, settings) -> new BaseGateBlock( + complexMaterial.getBlock(WoodSlots.PLANKS), + parentMaterial.woodType.type() + ); + } + + @Override + protected void modifyBlockEntry(WoodenComplexMaterial parentMaterial, @NotNull BlockEntry entry) { + entry.setBlockTags(BlockTags.FENCE_GATES); + } + + @Override + protected @Nullable void getRecipeSupplier(ComplexMaterial parentMaterial, ResourceLocation id) { + BCLRecipeBuilder.crafting(id, parentMaterial.getBlock(suffix)) + .setShape("I#I", "I#I") + .addMaterial('#', parentMaterial.getBlock(WoodSlots.PLANKS)) + .addMaterial('I', Items.STICK) + .setGroup("gate") + .setCategory(RecipeCategory.REDSTONE) + .build(); + } +} diff --git a/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Ladder.java b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Ladder.java new file mode 100644 index 00000000..90a2c30f --- /dev/null +++ b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Ladder.java @@ -0,0 +1,50 @@ +package org.betterx.bclib.complexmaterials.set.wood; + +import org.betterx.bclib.blocks.BaseLadderBlock; +import org.betterx.bclib.complexmaterials.ComplexMaterial; +import org.betterx.bclib.complexmaterials.WoodenComplexMaterial; +import org.betterx.bclib.complexmaterials.entry.BlockEntry; +import org.betterx.bclib.complexmaterials.entry.SimpleMaterialSlot; +import org.betterx.bclib.recipes.BCLRecipeBuilder; + +import net.minecraft.data.recipes.RecipeCategory; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.BlockTags; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockBehaviour; + +import java.util.function.BiFunction; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class Ladder extends SimpleMaterialSlot { + public Ladder() { + super("ladder"); + } + + @Override + protected @NotNull BiFunction getBlockSupplier( + WoodenComplexMaterial parentMaterial + ) { + return (complexMaterial, settings) -> new BaseLadderBlock(complexMaterial.getBlock(WoodSlots.PLANKS)); + } + + @Override + protected void modifyBlockEntry(WoodenComplexMaterial parentMaterial, @NotNull BlockEntry entry) { + entry.setBlockTags(BlockTags.CLIMBABLE); + } + + @Override + protected @Nullable void getRecipeSupplier(ComplexMaterial parentMaterial, ResourceLocation id) { + BCLRecipeBuilder + .crafting(id, parentMaterial.getBlock(suffix)) + .setOutputCount(3) + .setShape("I I", "I#I", "I I") + .addMaterial('#', parentMaterial.getBlock(WoodSlots.PLANKS)) + .addMaterial('I', Items.STICK) + .setGroup("ladder") + .setCategory(RecipeCategory.DECORATIONS) + .build(); + } +} diff --git a/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Log.java b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Log.java new file mode 100644 index 00000000..e11e41a7 --- /dev/null +++ b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Log.java @@ -0,0 +1,61 @@ +package org.betterx.bclib.complexmaterials.set.wood; + +import org.betterx.bclib.blocks.BaseStripableLogBlock; +import org.betterx.bclib.complexmaterials.ComplexMaterial; +import org.betterx.bclib.complexmaterials.WoodenComplexMaterial; +import org.betterx.bclib.complexmaterials.entry.BlockEntry; +import org.betterx.bclib.complexmaterials.entry.SimpleMaterialSlot; +import org.betterx.bclib.recipes.BCLRecipeBuilder; + +import net.minecraft.data.recipes.RecipeCategory; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.BlockTags; +import net.minecraft.tags.ItemTags; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockBehaviour; + +import java.util.function.BiFunction; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class Log extends SimpleMaterialSlot { + public Log() { + super("log"); + } + + @Override + protected @NotNull BiFunction getBlockSupplier( + WoodenComplexMaterial parentMaterial + ) { + return (complexMaterial, settings) -> new BaseStripableLogBlock( + parentMaterial.woodColor, + complexMaterial.getBlock(WoodSlots.STRIPPED_LOG) + ); + } + + @Override + protected void modifyBlockEntry(WoodenComplexMaterial parentMaterial, @NotNull BlockEntry entry) { + entry + .setBlockTags( + BlockTags.LOGS, + BlockTags.LOGS_THAT_BURN, + parentMaterial.getBlockTag(WoodenComplexMaterial.TAG_LOGS) + ) + .setItemTags( + ItemTags.LOGS, + ItemTags.LOGS_THAT_BURN, + parentMaterial.getItemTag(WoodenComplexMaterial.TAG_LOGS) + ); + } + + @Override + protected @Nullable void getRecipeSupplier(ComplexMaterial material, ResourceLocation id) { + BCLRecipeBuilder + .crafting(id, material.getBlock(suffix)) + .setShape("##", "##") + .addMaterial('#', material.getBlock(WoodSlots.BARK)) + .setOutputCount(3) + .setCategory(RecipeCategory.BUILDING_BLOCKS) + .build(); + } +} diff --git a/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Planks.java b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Planks.java new file mode 100644 index 00000000..e57136ec --- /dev/null +++ b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Planks.java @@ -0,0 +1,56 @@ +package org.betterx.bclib.complexmaterials.set.wood; + +import org.betterx.bclib.blocks.BaseBlock; +import org.betterx.bclib.complexmaterials.ComplexMaterial; +import org.betterx.bclib.complexmaterials.WoodenComplexMaterial; +import org.betterx.bclib.complexmaterials.entry.BlockEntry; +import org.betterx.bclib.complexmaterials.entry.SimpleMaterialSlot; +import org.betterx.bclib.recipes.BCLRecipeBuilder; + +import net.minecraft.data.recipes.RecipeCategory; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.BlockTags; +import net.minecraft.tags.ItemTags; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockBehaviour; + +import java.util.function.BiFunction; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class Planks extends SimpleMaterialSlot { + public Planks() { + super("planks"); + } + + @Override + protected @NotNull BiFunction getBlockSupplier( + WoodenComplexMaterial parentMaterial + ) { + return (complexMaterial, settings) -> new BaseBlock(settings); + } + + @Override + protected void modifyBlockEntry(WoodenComplexMaterial parentMaterial, @NotNull BlockEntry entry) { + entry + .setBlockTags(BlockTags.PLANKS) + .setItemTags(ItemTags.PLANKS); + } + + @Override + protected @Nullable void getRecipeSupplier(ComplexMaterial parentMaterial, ResourceLocation id) { + BCLRecipeBuilder.crafting(id, parentMaterial.getBlock(suffix)) + .setOutputCount(4) + .shapeless() + .addMaterial( + '#', + parentMaterial.getBlock(WoodSlots.LOG), + parentMaterial.getBlock(WoodSlots.BARK), + parentMaterial.getBlock(WoodSlots.STRIPPED_LOG), + parentMaterial.getBlock(WoodSlots.STRIPPED_BARK) + ) + .setGroup("planks") + .setCategory(RecipeCategory.BUILDING_BLOCKS) + .build(); + } +} diff --git a/src/main/java/org/betterx/bclib/complexmaterials/set/wood/PressurePlate.java b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/PressurePlate.java new file mode 100644 index 00000000..d922488a --- /dev/null +++ b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/PressurePlate.java @@ -0,0 +1,52 @@ +package org.betterx.bclib.complexmaterials.set.wood; + +import org.betterx.bclib.blocks.WoodenPressurePlateBlock; +import org.betterx.bclib.complexmaterials.ComplexMaterial; +import org.betterx.bclib.complexmaterials.WoodenComplexMaterial; +import org.betterx.bclib.complexmaterials.entry.BlockEntry; +import org.betterx.bclib.complexmaterials.entry.SimpleMaterialSlot; +import org.betterx.bclib.recipes.BCLRecipeBuilder; + +import net.minecraft.data.recipes.RecipeCategory; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.BlockTags; +import net.minecraft.tags.ItemTags; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockBehaviour; + +import java.util.function.BiFunction; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class PressurePlate extends SimpleMaterialSlot { + public PressurePlate() { + super("plate"); + } + + @Override + protected @NotNull BiFunction getBlockSupplier( + WoodenComplexMaterial parentMaterial + ) { + return (complexMaterial, settings) -> new WoodenPressurePlateBlock( + complexMaterial.getBlock(WoodSlots.PLANKS), + parentMaterial.woodType.setType() + ); + } + + @Override + protected void modifyBlockEntry(WoodenComplexMaterial parentMaterial, @NotNull BlockEntry entry) { + entry.setBlockTags(BlockTags.PRESSURE_PLATES, BlockTags.WOODEN_PRESSURE_PLATES) + .setItemTags(ItemTags.WOODEN_PRESSURE_PLATES); + } + + @Override + protected @Nullable void getRecipeSupplier(ComplexMaterial parentMaterial, ResourceLocation id) { + BCLRecipeBuilder + .crafting(id, parentMaterial.getBlock(suffix)) + .setShape("##") + .addMaterial('#', parentMaterial.getBlock(WoodSlots.PLANKS)) + .setGroup("pressure_plate") + .setCategory(RecipeCategory.REDSTONE) + .build(); + } +} diff --git a/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Sign.java b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Sign.java new file mode 100644 index 00000000..4f141ee5 --- /dev/null +++ b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Sign.java @@ -0,0 +1,65 @@ +package org.betterx.bclib.complexmaterials.set.wood; + +import org.betterx.bclib.blocks.BaseSignBlock; +import org.betterx.bclib.complexmaterials.WoodenComplexMaterial; +import org.betterx.bclib.complexmaterials.entry.BlockEntry; +import org.betterx.bclib.complexmaterials.entry.MaterialSlot; +import org.betterx.bclib.complexmaterials.entry.RecipeEntry; +import org.betterx.bclib.recipes.BCLRecipeBuilder; + +import net.minecraft.data.recipes.RecipeCategory; +import net.minecraft.tags.BlockTags; +import net.minecraft.tags.ItemTags; +import net.minecraft.world.item.Items; + +import java.util.function.Consumer; +import org.jetbrains.annotations.NotNull; + +public class Sign extends MaterialSlot { + @NotNull + public static final String WALL_SUFFFIX = "wall_sign"; + + public Sign() { + super("sign"); + } + + @Override + public void addBlockEntry(WoodenComplexMaterial parentMaterial, Consumer adder) { + var signEntry = new BlockEntry( + suffix, + (complexMaterial, settings) -> new BaseSignBlock(parentMaterial.woodType) + ).setBlockTags(BlockTags.SIGNS) + .setItemTags(ItemTags.SIGNS); + + var wallSignEntry = new BlockEntry( + WALL_SUFFFIX, + false, + (complexMaterial, settings) -> { + if (complexMaterial.getBlock(suffix) instanceof BaseSignBlock sign) { + return sign.wallSign; + } + return null; + } + ).setBlockTags(BlockTags.WALL_SIGNS); + adder.accept(signEntry); + adder.accept(wallSignEntry); + } + + @Override + public void addRecipeEntry( + WoodenComplexMaterial parentMaterial, + Consumer adder + ) { + adder.accept(new RecipeEntry(suffix, (mat, id) -> + BCLRecipeBuilder + .crafting(id, parentMaterial.getBlock(suffix)) + .setOutputCount(3) + .setShape("###", "###", " I ") + .addMaterial('#', parentMaterial.getBlock(WoodSlots.PLANKS)) + .addMaterial('I', Items.STICK) + .setGroup("sign") + .setCategory(RecipeCategory.DECORATIONS) + .build() + )); + } +} diff --git a/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Slab.java b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Slab.java new file mode 100644 index 00000000..4b455ad6 --- /dev/null +++ b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Slab.java @@ -0,0 +1,50 @@ +package org.betterx.bclib.complexmaterials.set.wood; + +import org.betterx.bclib.blocks.BaseSlabBlock; +import org.betterx.bclib.complexmaterials.ComplexMaterial; +import org.betterx.bclib.complexmaterials.WoodenComplexMaterial; +import org.betterx.bclib.complexmaterials.entry.BlockEntry; +import org.betterx.bclib.complexmaterials.entry.SimpleMaterialSlot; +import org.betterx.bclib.recipes.BCLRecipeBuilder; + +import net.minecraft.data.recipes.RecipeCategory; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.BlockTags; +import net.minecraft.tags.ItemTags; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockBehaviour; + +import java.util.function.BiFunction; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class Slab extends SimpleMaterialSlot { + public Slab() { + super("slab"); + } + + @Override + protected @NotNull BiFunction getBlockSupplier( + WoodenComplexMaterial parentMaterial + ) { + return (complexMaterial, settings) -> new BaseSlabBlock(complexMaterial.getBlock(WoodSlots.PLANKS), false); + } + + @Override + protected void modifyBlockEntry(WoodenComplexMaterial parentMaterial, @NotNull BlockEntry entry) { + entry.setBlockTags(BlockTags.WOODEN_SLABS, BlockTags.SLABS) + .setItemTags(ItemTags.WOODEN_SLABS, ItemTags.SLABS); + } + + @Override + protected @Nullable void getRecipeSupplier(ComplexMaterial parentMaterial, ResourceLocation id) { + BCLRecipeBuilder + .crafting(id, parentMaterial.getBlock(suffix)) + .setOutputCount(6) + .setShape("###") + .addMaterial('#', parentMaterial.getBlock(WoodSlots.PLANKS)) + .setGroup("slab") + .setCategory(RecipeCategory.BUILDING_BLOCKS) + .build(); + } +} diff --git a/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Stairs.java b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Stairs.java new file mode 100644 index 00000000..f497dfc4 --- /dev/null +++ b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Stairs.java @@ -0,0 +1,50 @@ +package org.betterx.bclib.complexmaterials.set.wood; + +import org.betterx.bclib.blocks.BaseStairsBlock; +import org.betterx.bclib.complexmaterials.ComplexMaterial; +import org.betterx.bclib.complexmaterials.WoodenComplexMaterial; +import org.betterx.bclib.complexmaterials.entry.BlockEntry; +import org.betterx.bclib.complexmaterials.entry.SimpleMaterialSlot; +import org.betterx.bclib.recipes.BCLRecipeBuilder; + +import net.minecraft.data.recipes.RecipeCategory; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.BlockTags; +import net.minecraft.tags.ItemTags; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockBehaviour; + +import java.util.function.BiFunction; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class Stairs extends SimpleMaterialSlot { + public Stairs() { + super("stairs"); + } + + @Override + protected @NotNull BiFunction getBlockSupplier( + WoodenComplexMaterial parentMaterial + ) { + return (complexMaterial, settings) -> new BaseStairsBlock(complexMaterial.getBlock(WoodSlots.PLANKS), false); + } + + @Override + protected void modifyBlockEntry(WoodenComplexMaterial parentMaterial, @NotNull BlockEntry entry) { + entry.setBlockTags(BlockTags.WOODEN_STAIRS, BlockTags.STAIRS) + .setItemTags(ItemTags.WOODEN_STAIRS, ItemTags.STAIRS); + } + + @Override + protected @Nullable void getRecipeSupplier(ComplexMaterial parentMaterial, ResourceLocation id) { + BCLRecipeBuilder + .crafting(id, parentMaterial.getBlock(suffix)) + .setOutputCount(4) + .setShape("# ", "## ", "###") + .addMaterial('#', parentMaterial.getBlock(WoodSlots.PLANKS)) + .setGroup("stairs") + .setCategory(RecipeCategory.BUILDING_BLOCKS) + .build(); + } +} diff --git a/src/main/java/org/betterx/bclib/complexmaterials/set/wood/StrippedBark.java b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/StrippedBark.java new file mode 100644 index 00000000..4738d81e --- /dev/null +++ b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/StrippedBark.java @@ -0,0 +1,58 @@ +package org.betterx.bclib.complexmaterials.set.wood; + +import org.betterx.bclib.blocks.BaseBarkBlock; +import org.betterx.bclib.complexmaterials.ComplexMaterial; +import org.betterx.bclib.complexmaterials.WoodenComplexMaterial; +import org.betterx.bclib.complexmaterials.entry.BlockEntry; +import org.betterx.bclib.complexmaterials.entry.SimpleMaterialSlot; +import org.betterx.bclib.recipes.BCLRecipeBuilder; + +import net.minecraft.data.recipes.RecipeCategory; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.BlockTags; +import net.minecraft.tags.ItemTags; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockBehaviour; + +import java.util.function.BiFunction; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class StrippedBark extends SimpleMaterialSlot { + public StrippedBark() { + super("stripped_bark"); + } + + @Override + protected @NotNull BiFunction getBlockSupplier( + WoodenComplexMaterial parentMaterial + ) { + return (complexMaterial, settings) -> new BaseBarkBlock(settings); + } + + @Override + protected void modifyBlockEntry(WoodenComplexMaterial parentMaterial, @NotNull BlockEntry entry) { + entry + .setBlockTags( + BlockTags.LOGS, + BlockTags.LOGS_THAT_BURN, + parentMaterial.getBlockTag(WoodenComplexMaterial.TAG_LOGS) + ) + .setItemTags( + ItemTags.LOGS, + ItemTags.LOGS_THAT_BURN, + parentMaterial.getItemTag(WoodenComplexMaterial.TAG_LOGS) + ); + } + + @Override + protected @Nullable void getRecipeSupplier(ComplexMaterial material, ResourceLocation id) { + BCLRecipeBuilder + .crafting(id, material.getBlock(suffix)) + .setShape("##", "##") + .addMaterial('#', material.getBlock(WoodSlots.STRIPPED_LOG)) + .setOutputCount(3) + .setCategory(RecipeCategory.BUILDING_BLOCKS) + .build(); + } +} diff --git a/src/main/java/org/betterx/bclib/complexmaterials/set/wood/StrippedLog.java b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/StrippedLog.java new file mode 100644 index 00000000..1e42c14b --- /dev/null +++ b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/StrippedLog.java @@ -0,0 +1,57 @@ +package org.betterx.bclib.complexmaterials.set.wood; + +import org.betterx.bclib.blocks.BaseRotatedPillarBlock; +import org.betterx.bclib.complexmaterials.ComplexMaterial; +import org.betterx.bclib.complexmaterials.WoodenComplexMaterial; +import org.betterx.bclib.complexmaterials.entry.BlockEntry; +import org.betterx.bclib.complexmaterials.entry.SimpleMaterialSlot; +import org.betterx.bclib.recipes.BCLRecipeBuilder; + +import net.minecraft.data.recipes.RecipeCategory; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.BlockTags; +import net.minecraft.tags.ItemTags; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockBehaviour; + +import java.util.function.BiFunction; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class StrippedLog extends SimpleMaterialSlot { + protected StrippedLog() { + super("stripped_log"); + } + + @Override + @NotNull + protected BiFunction getBlockSupplier(WoodenComplexMaterial parentMaterial) { + return (complexMaterial, settings) -> new BaseRotatedPillarBlock(settings); + } + + @Override + protected void modifyBlockEntry(WoodenComplexMaterial parentMaterial, @NotNull BlockEntry entry) { + entry + .setBlockTags( + BlockTags.LOGS, + BlockTags.LOGS_THAT_BURN, + parentMaterial.getBlockTag(WoodenComplexMaterial.TAG_LOGS) + ) + .setItemTags( + ItemTags.LOGS, + ItemTags.LOGS_THAT_BURN, + parentMaterial.getItemTag(WoodenComplexMaterial.TAG_LOGS) + ); + } + + @Override + protected @Nullable void getRecipeSupplier(ComplexMaterial material, ResourceLocation id) { + BCLRecipeBuilder + .crafting(id, material.getBlock(suffix)) + .setShape("##", "##") + .addMaterial('#', material.getBlock(WoodSlots.STRIPPED_BARK)) + .setOutputCount(3) + .setCategory(RecipeCategory.BUILDING_BLOCKS) + .build(); + } +} diff --git a/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Trapdoor.java b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Trapdoor.java new file mode 100644 index 00000000..19fac5d3 --- /dev/null +++ b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/Trapdoor.java @@ -0,0 +1,52 @@ +package org.betterx.bclib.complexmaterials.set.wood; + +import org.betterx.bclib.blocks.BaseTrapdoorBlock; +import org.betterx.bclib.complexmaterials.ComplexMaterial; +import org.betterx.bclib.complexmaterials.WoodenComplexMaterial; +import org.betterx.bclib.complexmaterials.entry.BlockEntry; +import org.betterx.bclib.complexmaterials.entry.SimpleMaterialSlot; +import org.betterx.bclib.recipes.BCLRecipeBuilder; + +import net.minecraft.data.recipes.RecipeCategory; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.BlockTags; +import net.minecraft.tags.ItemTags; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockBehaviour; + +import java.util.function.BiFunction; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class Trapdoor extends SimpleMaterialSlot { + public Trapdoor() { + super("trapdoor"); + } + + @Override + protected @NotNull BiFunction getBlockSupplier( + WoodenComplexMaterial parentMaterial + ) { + return (complexMaterial, settings) -> new BaseTrapdoorBlock( + complexMaterial.getBlock(WoodSlots.PLANKS), + parentMaterial.woodType.setType() + ); + } + + @Override + protected void modifyBlockEntry(WoodenComplexMaterial parentMaterial, @NotNull BlockEntry entry) { + entry.setBlockTags(BlockTags.TRAPDOORS, BlockTags.WOODEN_TRAPDOORS) + .setItemTags(ItemTags.TRAPDOORS, ItemTags.WOODEN_TRAPDOORS); + } + + @Override + protected @Nullable void getRecipeSupplier(ComplexMaterial parentMaterial, ResourceLocation id) { + BCLRecipeBuilder.crafting(id, parentMaterial.getBlock(suffix)) + .setOutputCount(2) + .setShape("###", "###") + .addMaterial('#', parentMaterial.getBlock(WoodSlots.PLANKS)) + .setGroup("trapdoor") + .setCategory(RecipeCategory.REDSTONE) + .build(); + } +} diff --git a/src/main/java/org/betterx/bclib/complexmaterials/set/wood/WoodSlots.java b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/WoodSlots.java new file mode 100644 index 00000000..115276be --- /dev/null +++ b/src/main/java/org/betterx/bclib/complexmaterials/set/wood/WoodSlots.java @@ -0,0 +1,32 @@ +package org.betterx.bclib.complexmaterials.set.wood; + +import org.betterx.bclib.complexmaterials.WoodenComplexMaterial; +import org.betterx.bclib.complexmaterials.entry.MaterialSlot; + +public class WoodSlots { + public static final MaterialSlot STRIPPED_LOG = new StrippedLog(); + public static final MaterialSlot STRIPPED_BARK = new StrippedBark(); + public static final MaterialSlot LOG = new Log(); + public static final MaterialSlot BARK = new Bark(); + public static final MaterialSlot PLANKS = new Planks(); + public static final MaterialSlot STAIRS = new Stairs(); + public static final MaterialSlot SLAB = new Slab(); + public static final MaterialSlot FENCE = new Fence(); + public static final MaterialSlot GATE = new Gate(); + public static final MaterialSlot BUTTON = new Button(); + public static final MaterialSlot PRESSURE_PLATE = new PressurePlate(); + public static final MaterialSlot TRAPDOOR = new Trapdoor(); + public static final MaterialSlot DOOR = new Door(); + public static final MaterialSlot LADDER = new Ladder(); + public static final Sign SIGN = new Sign(); + public static final String WALL_SIGN = Sign.WALL_SUFFFIX; + public static final MaterialSlot CHEST = new Chest(); + public static final MaterialSlot BARREL = new Barrel(); + public static final MaterialSlot CRAFTING_TABLE = new CraftingTable(); + public static final MaterialSlot BOOKSHELF = new Bookshelf(); + public static final MaterialSlot COMPOSTER = new Composter(); + public static final MaterialSlot BOAT = new Boat(); + public static final MaterialSlot CHEST_BOAT = new ChestBoat(); +} + +