From 119d288433628dc32f2d733a9a3433753d6dd430 Mon Sep 17 00:00:00 2001 From: Jingy <69827559+Jiingy@users.noreply.github.com> Date: Fri, 14 Apr 2023 21:21:12 -0500 Subject: [PATCH] Improves redundant code for the jineric wooden chests Notes: - Breaks the shulker chest, will need to be fixed Signed-off-by: Jingy <69827559+Jiingy@users.noreply.github.com> --- gradle.properties | 2 +- .../jingy/jineric/block/JinericBlocks.java | 22 +-- .../jineric/block/JinericChestBlock.java | 41 +++--- .../jineric/block/ShulkerChestBlock.java | 25 ++-- .../block/entity/JinericChestBlockEntity.java | 51 ++++--- .../block/entity/ShulkerChestBlockEntity.java | 8 +- .../entity/chests/AcaciaChestBlockEntity.java | 12 -- .../entity/chests/BirchChestBlockEntity.java | 12 -- .../entity/chests/BorealChestBlockEntity.java | 12 -- .../chests/CrimsonChestBlockEntity.java | 12 -- .../chests/DarkOakChestBlockEntity.java | 12 -- .../entity/chests/JungleChestBlockEntity.java | 12 -- .../chests/MangroveChestBlockEntity.java | 12 -- .../entity/chests/SpruceChestBlockEntity.java | 12 -- .../entity/chests/WarpedChestBlockEntity.java | 12 -- .../jineric/block/enums/JinericChestType.java | 70 +++++----- .../render/JinericTextureRenderLayers.java | 129 +++++++++--------- .../jingy/jineric/item/JinericItemGroups.java | 2 +- .../java/jingy/jineric/item/JinericItems.java | 6 +- .../mixin/ChestBlockEntityRendererMixin.java | 7 +- .../registry/JinericBlockEntityRenderer.java | 12 +- .../registry/JinericBlockEntityType.java | 68 +++------ 22 files changed, 212 insertions(+), 339 deletions(-) delete mode 100644 src/main/java/jingy/jineric/block/entity/chests/AcaciaChestBlockEntity.java delete mode 100644 src/main/java/jingy/jineric/block/entity/chests/BirchChestBlockEntity.java delete mode 100644 src/main/java/jingy/jineric/block/entity/chests/BorealChestBlockEntity.java delete mode 100644 src/main/java/jingy/jineric/block/entity/chests/CrimsonChestBlockEntity.java delete mode 100644 src/main/java/jingy/jineric/block/entity/chests/DarkOakChestBlockEntity.java delete mode 100644 src/main/java/jingy/jineric/block/entity/chests/JungleChestBlockEntity.java delete mode 100644 src/main/java/jingy/jineric/block/entity/chests/MangroveChestBlockEntity.java delete mode 100644 src/main/java/jingy/jineric/block/entity/chests/SpruceChestBlockEntity.java delete mode 100644 src/main/java/jingy/jineric/block/entity/chests/WarpedChestBlockEntity.java diff --git a/gradle.properties b/gradle.properties index 519b54ca..f36631c1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,5 +16,5 @@ org.gradle.parallel = true # Mod Properties mod_name = Jineric Mod mod_id = jineric - version = b4.2.0+1.19.4 + version = b4.3.0+1.19.4 maven_group = jingy.jineric diff --git a/src/main/java/jingy/jineric/block/JinericBlocks.java b/src/main/java/jingy/jineric/block/JinericBlocks.java index 6323e5e2..fe816162 100644 --- a/src/main/java/jingy/jineric/block/JinericBlocks.java +++ b/src/main/java/jingy/jineric/block/JinericBlocks.java @@ -1,7 +1,7 @@ package jingy.jineric.block; import jingy.jineric.base.JinericMain; -import jingy.jineric.block.enums.JinericChestType; +import jingy.jineric.registry.JinericBlockEntityType; import jingy.jineric.registry.JinericBlockSettings; import jingy.jineric.sound.JinericSoundGroups; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; @@ -280,16 +280,16 @@ public class JinericBlocks { public static final Block WAXED_OXIDIZED_CUT_COPPER_WALL = register("waxed_oxidized_cut_copper_wall", new OxidizableCopperWallBlock(Oxidizable.OxidationLevel.OXIDIZED, FabricBlockSettings.copy(OXIDIZED_CUT_COPPER))); //CHESTS - public static final Block ACACIA_CHEST = register("acacia_chest", new JinericChestBlock(FabricBlockSettings.copy(CHEST), JinericChestType.ACACIA)); - public static final Block BIRCH_CHEST = register("birch_chest", new JinericChestBlock(FabricBlockSettings.copy(CHEST), JinericChestType.BIRCH)); -// public static final Block BOREAL_CHEST = register("boreal_chest", new FabricBlockSettingsBase(FabricBlockSettings.copy(CHEST), JinericChestType.BOREAL)); - public static final Block CRIMSON_CHEST = register("crimson_chest", new JinericChestBlock(FabricBlockSettings.copy(CHEST), JinericChestType.CRIMSON) ); - public static final Block DARK_OAK_CHEST = register("dark_oak_chest", new JinericChestBlock(FabricBlockSettings.copy(CHEST), JinericChestType.DARK_OAK)); - public static final Block JUNGLE_CHEST = register("jungle_chest", new JinericChestBlock(FabricBlockSettings.copy(CHEST), JinericChestType.JUNGLE)); - public static final Block SHULKER_CHEST = register("shulker_chest", new ShulkerChestBlock(FabricBlockSettings.of(Material.STONE), JinericChestType.SHULKER)); - public static final Block SPRUCE_CHEST = register("spruce_chest", new JinericChestBlock(FabricBlockSettings.copy(CHEST), JinericChestType.SPRUCE)); - public static final Block WARPED_CHEST = register("warped_chest", new JinericChestBlock(FabricBlockSettings.copy(CHEST), JinericChestType.WARPED)); - public static final Block MANGROVE_CHEST = register("mangrove_chest", new JinericChestBlock(FabricBlockSettings.copy(CHEST), JinericChestType.MANGROVE)); + public static final Block ACACIA_CHEST = register("acacia_chest", new JinericChestBlock(FabricBlockSettings.copy(CHEST), () -> JinericBlockEntityType.JINERIC_CHEST, WoodType.ACACIA)); + public static final Block BIRCH_CHEST = register("birch_chest", new JinericChestBlock(FabricBlockSettings.copy(CHEST), () -> JinericBlockEntityType.JINERIC_CHEST, WoodType.BIRCH)); +//// public static final Block BOREAL_CHEST = register("boreal_chest", new FabricBlockSettingsBase(FabricBlockSettings.copy(CHEST), JinericChestType.BOREAL)); + public static final Block CRIMSON_CHEST = register("crimson_chest", new JinericChestBlock(FabricBlockSettings.copy(CHEST), () -> JinericBlockEntityType.JINERIC_CHEST, WoodType.CRIMSON) ); + public static final Block DARK_OAK_CHEST = register("dark_oak_chest", new JinericChestBlock(FabricBlockSettings.copy(CHEST), () -> JinericBlockEntityType.JINERIC_CHEST, WoodType.DARK_OAK)); + public static final Block JUNGLE_CHEST = register("jungle_chest", new JinericChestBlock(FabricBlockSettings.copy(CHEST), () -> JinericBlockEntityType.JINERIC_CHEST, WoodType.JUNGLE)); +// public static final Block SHULKER_CHEST = register("shulker_chest", new ShulkerChestBlock(FabricBlockSettings.of(Material.STONE), () -> JinericBlockEntityType.JINERIC_CHEST, WoodType.SHULKER)); + public static final Block SPRUCE_CHEST = register("spruce_chest", new JinericChestBlock(FabricBlockSettings.copy(CHEST), () -> JinericBlockEntityType.JINERIC_CHEST, WoodType.SPRUCE)); + public static final Block WARPED_CHEST = register("warped_chest", new JinericChestBlock(FabricBlockSettings.copy(CHEST), () -> JinericBlockEntityType.JINERIC_CHEST, WoodType.WARPED)); + public static final Block MANGROVE_CHEST = register("mangrove_chest", new JinericChestBlock(FabricBlockSettings.copy(CHEST), () -> JinericBlockEntityType.JINERIC_CHEST, WoodType.MANGROVE)); public static final Block REFINERY = register("refinery", new RefineryBlock(FabricBlockSettings.copy(FURNACE).luminance(state -> 13))); diff --git a/src/main/java/jingy/jineric/block/JinericChestBlock.java b/src/main/java/jingy/jineric/block/JinericChestBlock.java index c753f9ac..38b4aa18 100644 --- a/src/main/java/jingy/jineric/block/JinericChestBlock.java +++ b/src/main/java/jingy/jineric/block/JinericChestBlock.java @@ -1,13 +1,12 @@ package jingy.jineric.block; import jingy.jineric.block.entity.JinericChestBlockEntity; -import jingy.jineric.block.enums.JinericChestType; -import net.minecraft.block.BlockState; -import net.minecraft.block.ChestBlock; -import net.minecraft.block.DoubleBlockProperties; +import jingy.jineric.registry.JinericBlockEntityType; +import net.minecraft.block.*; import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntityTicker; import net.minecraft.block.entity.BlockEntityType; +import net.minecraft.block.entity.ChestBlockEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.DoubleInventory; @@ -15,7 +14,6 @@ import net.minecraft.screen.GenericContainerScreenHandler; import net.minecraft.screen.NamedScreenHandlerFactory; import net.minecraft.screen.ScreenHandler; -import net.minecraft.text.Text; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.WorldAccess; @@ -23,22 +21,22 @@ import java.util.Optional; import java.util.function.BiPredicate; +import java.util.function.Supplier; public class JinericChestBlock extends ChestBlock { - private final JinericChestType type; + private final WoodType type; - public JinericChestBlock(Settings settings, JinericChestType type) { - super(settings, type::getBlockEntityType); + public JinericChestBlock(Settings settings, Supplier> supplier, WoodType type) { + super(settings, supplier); this.type = type; } @Override public BlockEntity createBlockEntity(BlockPos pos, BlockState state) { - return this.type.getEntity(pos, state); + return new JinericChestBlockEntity(JinericBlockEntityType.JINERIC_CHEST, pos, state); } private static final DoubleBlockProperties.PropertyRetriever> NAME_RETRIEVER = new DoubleBlockProperties.PropertyRetriever<>() { - public Optional getFromBoth(JinericChestBlockEntity jinericChestBlockEntity, JinericChestBlockEntity jinericChestBlockEntity2) { final Inventory inventory = new DoubleInventory(jinericChestBlockEntity, jinericChestBlockEntity2); return Optional.of(new NamedScreenHandlerFactory() { @@ -53,29 +51,39 @@ public ScreenHandler createMenu(int i, PlayerInventory playerInventory, PlayerEn return null; } } - @Override public net.minecraft.text.Text getDisplayName() { if (jinericChestBlockEntity.hasCustomName()) { return jinericChestBlockEntity.getDisplayName(); } else { - return (Text) (jinericChestBlockEntity2.hasCustomName() ? jinericChestBlockEntity2.getDisplayName() : jinericChestBlockEntity.getChestTypeKey()); + BlockState blockState = jinericChestBlockEntity.getCachedState(); + WoodType woodType = JinericChestBlock.getWoodType(blockState.getBlock()); + return (jinericChestBlockEntity2.hasCustomName() ? jinericChestBlockEntity2.getDisplayName() : jinericChestBlockEntity.getChestTypeKey(woodType)); } } }); } - public Optional getFrom(JinericChestBlockEntity chestBlockEntity) { return Optional.of(chestBlockEntity); } - public Optional getFallback() { return Optional.empty(); } }; - public JinericChestType getType() { - return type; + public WoodType getWoodType() { + return this.type; + } + + public static WoodType getWoodType(Block block) { + WoodType woodType; + if (block instanceof JinericChestBlock) { + woodType = ((JinericChestBlock)block).getWoodType(); + } + else { + woodType = WoodType.OAK; + } + return woodType; } public BlockEntityType getExpectedEntityType() { @@ -92,7 +100,6 @@ public DoubleBlockProperties.PropertySource g } else { biPredicate = JinericChestBlock::isChestBlocked; } - return DoubleBlockProperties.toPropertySource( (BlockEntityType)this.entityTypeRetriever.get(), JinericChestBlock::getDoubleBlockType, JinericChestBlock::getFacing, diff --git a/src/main/java/jingy/jineric/block/ShulkerChestBlock.java b/src/main/java/jingy/jineric/block/ShulkerChestBlock.java index 5ca6850b..6de4f7f9 100644 --- a/src/main/java/jingy/jineric/block/ShulkerChestBlock.java +++ b/src/main/java/jingy/jineric/block/ShulkerChestBlock.java @@ -1,22 +1,19 @@ package jingy.jineric.block; -import jingy.jineric.block.entity.ShulkerChestBlockEntity; -import jingy.jineric.block.enums.JinericChestType; -import jingy.jineric.registry.JinericBlockEntityType; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.block.BlockState; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.block.entity.BlockEntityTicker; +import net.minecraft.block.WoodType; import net.minecraft.block.entity.BlockEntityType; +import net.minecraft.block.entity.ChestBlockEntity; import net.minecraft.fluid.FluidState; import net.minecraft.fluid.Fluids; import net.minecraft.item.ItemPlacementContext; -import net.minecraft.world.World; -import org.jetbrains.annotations.Nullable; + +import java.util.function.Supplier; public class ShulkerChestBlock extends JinericChestBlock { - public ShulkerChestBlock(FabricBlockSettings settings, JinericChestType type) { - super(settings, type); + public ShulkerChestBlock(FabricBlockSettings settings, Supplier> supplier, WoodType type) { + super(settings, supplier, type); } @Override @@ -27,9 +24,9 @@ public BlockState getPlacementState(ItemPlacementContext ctx) { .with(WATERLOGGED, fluidState.getFluid() == Fluids.WATER); } - @Nullable - @Override - public BlockEntityTicker getTicker(World world, BlockState state, BlockEntityType type) { - return world.isClient ? checkType(type, JinericBlockEntityType.SHULKER_CHEST, ShulkerChestBlockEntity::clientTick) : null; - } +// @Nullable +// @Override +// public BlockEntityTicker getTicker(World world, BlockState state, BlockEntityType type) { +// return world.isClient ? checkType(type, JinericBlockEntityType.SHULKER_CHEST, ShulkerChestBlockEntity::clientTick) : null; +// } } diff --git a/src/main/java/jingy/jineric/block/entity/JinericChestBlockEntity.java b/src/main/java/jingy/jineric/block/entity/JinericChestBlockEntity.java index e34091ac..cfa30e74 100644 --- a/src/main/java/jingy/jineric/block/entity/JinericChestBlockEntity.java +++ b/src/main/java/jingy/jineric/block/entity/JinericChestBlockEntity.java @@ -1,43 +1,52 @@ package jingy.jineric.block.entity; -import jingy.jineric.block.enums.JinericChestType; +import jingy.jineric.registry.JinericBlockEntityType; import net.minecraft.block.BlockState; +import net.minecraft.block.WoodType; +import net.minecraft.block.entity.BlockEntityType; import net.minecraft.block.entity.ChestBlockEntity; import net.minecraft.item.ItemStack; import net.minecraft.text.Text; import net.minecraft.util.collection.DefaultedList; import net.minecraft.util.math.BlockPos; -public class JinericChestBlockEntity extends ChestBlockEntity { - private final JinericChestType type; +import static net.minecraft.block.WoodType.*; - public JinericChestBlockEntity(JinericChestType type, BlockPos blockPos, BlockState blockState) { - super(type.getBlockEntityType(), blockPos, blockState); - this.type = type; +public class JinericChestBlockEntity extends ChestBlockEntity { + public JinericChestBlockEntity(BlockEntityType type, BlockPos blockPos, BlockState blockState) { + super(type, blockPos, blockState); this.setInvStackList(DefaultedList.ofSize(this.size(), ItemStack.EMPTY)); } - public JinericChestType getChestType() { - return type; + public JinericChestBlockEntity(BlockPos blockPos, BlockState state) { + super(JinericBlockEntityType.JINERIC_CHEST, blockPos, state); } @Override public int size() { - return type.size; + return 27; } - public Text getChestTypeKey() { - return switch (getChestType()) { - case ACACIA -> Text.translatable("container.chestAcaciaDouble"); - case BIRCH -> Text.translatable("container.chestBirchDouble"); - case CRIMSON -> Text.translatable("container.chestCrimsonDouble"); - case DARK_OAK -> Text.translatable("container.chestDarkOakDouble"); - case JUNGLE -> Text.translatable("container.chestJungleDouble"); - case SPRUCE -> Text.translatable("container.chestSpruceDouble"); - case WARPED -> Text.translatable("container.chestWarpedDouble"); - case MANGROVE -> Text.translatable("container.chestMangroveDouble"); - case SHULKER -> null; - }; + public Text getChestTypeKey(WoodType woodType) { + if (woodType == ACACIA) { + return Text.translatable("container.chestAcaciaDouble"); + } else if (woodType == BIRCH) { + return Text.translatable("container.chestBirchDouble"); + } else if (woodType == CRIMSON) { + return Text.translatable("container.chestCrimsonDouble"); + } else if (woodType == DARK_OAK) { + return Text.translatable("container.chestDarkOakDouble"); + } else if (woodType == JUNGLE) { + return Text.translatable("container.chestJungleDouble"); + } else if (woodType == SPRUCE) { + return Text.translatable("container.chestSpruceDouble"); + } else if (woodType == WARPED) { + return Text.translatable("container.chestWarpedDouble"); + } else if (woodType == MANGROVE) { + return Text.translatable("container.chestMangroveDouble"); + } else { + return Text.literal("No Display Name Set"); + } } @Override diff --git a/src/main/java/jingy/jineric/block/entity/ShulkerChestBlockEntity.java b/src/main/java/jingy/jineric/block/entity/ShulkerChestBlockEntity.java index 41335d8e..bf898163 100644 --- a/src/main/java/jingy/jineric/block/entity/ShulkerChestBlockEntity.java +++ b/src/main/java/jingy/jineric/block/entity/ShulkerChestBlockEntity.java @@ -1,8 +1,9 @@ package jingy.jineric.block.entity; -import jingy.jineric.block.enums.JinericChestType; +import jingy.jineric.registry.JinericBlockEntityType; import jingy.jineric.screen.ShulkerChestScreenHandler; import net.minecraft.block.BlockState; +import net.minecraft.block.entity.ChestBlockEntity; import net.minecraft.block.entity.ChestLidAnimator; import net.minecraft.block.entity.ViewerCountManager; import net.minecraft.entity.player.PlayerEntity; @@ -17,15 +18,16 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -public class ShulkerChestBlockEntity extends JinericChestBlockEntity { +public class ShulkerChestBlockEntity extends ChestBlockEntity { private final ChestLidAnimator lidAnimator = new ChestLidAnimator(); + // @Nullable // private final DyeColor color; public ShulkerChestBlockEntity( // @Nullable DyeColor color, BlockPos blockPos, BlockState blockState) { - super(JinericChestType.SHULKER, blockPos, blockState); + super(JinericBlockEntityType.JINERIC_CHEST, blockPos, blockState); // this.color = color; this.setInvStackList(DefaultedList.ofSize(this.size(), ItemStack.EMPTY)); } diff --git a/src/main/java/jingy/jineric/block/entity/chests/AcaciaChestBlockEntity.java b/src/main/java/jingy/jineric/block/entity/chests/AcaciaChestBlockEntity.java deleted file mode 100644 index 7831e1cd..00000000 --- a/src/main/java/jingy/jineric/block/entity/chests/AcaciaChestBlockEntity.java +++ /dev/null @@ -1,12 +0,0 @@ -package jingy.jineric.block.entity.chests; - -import jingy.jineric.block.entity.JinericChestBlockEntity; -import jingy.jineric.block.enums.JinericChestType; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; - -public class AcaciaChestBlockEntity extends JinericChestBlockEntity { - public AcaciaChestBlockEntity(BlockPos blockPos, BlockState blockState) { - super(JinericChestType.ACACIA, blockPos, blockState); - } -} \ No newline at end of file diff --git a/src/main/java/jingy/jineric/block/entity/chests/BirchChestBlockEntity.java b/src/main/java/jingy/jineric/block/entity/chests/BirchChestBlockEntity.java deleted file mode 100644 index ed112102..00000000 --- a/src/main/java/jingy/jineric/block/entity/chests/BirchChestBlockEntity.java +++ /dev/null @@ -1,12 +0,0 @@ -package jingy.jineric.block.entity.chests; - -import jingy.jineric.block.entity.JinericChestBlockEntity; -import jingy.jineric.block.enums.JinericChestType; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; - -public class BirchChestBlockEntity extends JinericChestBlockEntity { - public BirchChestBlockEntity(BlockPos blockPos, BlockState blockState) { - super(JinericChestType.BIRCH, blockPos, blockState); - } -} \ No newline at end of file diff --git a/src/main/java/jingy/jineric/block/entity/chests/BorealChestBlockEntity.java b/src/main/java/jingy/jineric/block/entity/chests/BorealChestBlockEntity.java deleted file mode 100644 index bf7b68a1..00000000 --- a/src/main/java/jingy/jineric/block/entity/chests/BorealChestBlockEntity.java +++ /dev/null @@ -1,12 +0,0 @@ -package jingy.jineric.block.entity.chests; - -import jingy.jineric.block.entity.JinericChestBlockEntity; -import jingy.jineric.block.enums.JinericChestType; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; - -public class BorealChestBlockEntity extends JinericChestBlockEntity { - public BorealChestBlockEntity(BlockPos blockPos, BlockState blockState) { - super(JinericChestType.ACACIA, blockPos, blockState); - } -} diff --git a/src/main/java/jingy/jineric/block/entity/chests/CrimsonChestBlockEntity.java b/src/main/java/jingy/jineric/block/entity/chests/CrimsonChestBlockEntity.java deleted file mode 100644 index 0c36659d..00000000 --- a/src/main/java/jingy/jineric/block/entity/chests/CrimsonChestBlockEntity.java +++ /dev/null @@ -1,12 +0,0 @@ -package jingy.jineric.block.entity.chests; - -import jingy.jineric.block.entity.JinericChestBlockEntity; -import jingy.jineric.block.enums.JinericChestType; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; - -public class CrimsonChestBlockEntity extends JinericChestBlockEntity { - public CrimsonChestBlockEntity(BlockPos blockPos, BlockState blockState) { - super(JinericChestType.CRIMSON, blockPos, blockState); - } -} diff --git a/src/main/java/jingy/jineric/block/entity/chests/DarkOakChestBlockEntity.java b/src/main/java/jingy/jineric/block/entity/chests/DarkOakChestBlockEntity.java deleted file mode 100644 index 78579c7c..00000000 --- a/src/main/java/jingy/jineric/block/entity/chests/DarkOakChestBlockEntity.java +++ /dev/null @@ -1,12 +0,0 @@ -package jingy.jineric.block.entity.chests; - -import jingy.jineric.block.entity.JinericChestBlockEntity; -import jingy.jineric.block.enums.JinericChestType; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; - -public class DarkOakChestBlockEntity extends JinericChestBlockEntity { - public DarkOakChestBlockEntity(BlockPos blockPos, BlockState blockState) { - super(JinericChestType.DARK_OAK, blockPos, blockState); - } -} diff --git a/src/main/java/jingy/jineric/block/entity/chests/JungleChestBlockEntity.java b/src/main/java/jingy/jineric/block/entity/chests/JungleChestBlockEntity.java deleted file mode 100644 index c8424db0..00000000 --- a/src/main/java/jingy/jineric/block/entity/chests/JungleChestBlockEntity.java +++ /dev/null @@ -1,12 +0,0 @@ -package jingy.jineric.block.entity.chests; - -import jingy.jineric.block.entity.JinericChestBlockEntity; -import jingy.jineric.block.enums.JinericChestType; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; - -public class JungleChestBlockEntity extends JinericChestBlockEntity { - public JungleChestBlockEntity(BlockPos blockPos, BlockState blockState) { - super(JinericChestType.JUNGLE, blockPos, blockState); - } -} diff --git a/src/main/java/jingy/jineric/block/entity/chests/MangroveChestBlockEntity.java b/src/main/java/jingy/jineric/block/entity/chests/MangroveChestBlockEntity.java deleted file mode 100644 index 80b474d0..00000000 --- a/src/main/java/jingy/jineric/block/entity/chests/MangroveChestBlockEntity.java +++ /dev/null @@ -1,12 +0,0 @@ -package jingy.jineric.block.entity.chests; - -import jingy.jineric.block.entity.JinericChestBlockEntity; -import jingy.jineric.block.enums.JinericChestType; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; - -public class MangroveChestBlockEntity extends JinericChestBlockEntity { - public MangroveChestBlockEntity(BlockPos blockPos, BlockState blockState) { - super(JinericChestType.MANGROVE, blockPos, blockState); - } -} diff --git a/src/main/java/jingy/jineric/block/entity/chests/SpruceChestBlockEntity.java b/src/main/java/jingy/jineric/block/entity/chests/SpruceChestBlockEntity.java deleted file mode 100644 index ffa36883..00000000 --- a/src/main/java/jingy/jineric/block/entity/chests/SpruceChestBlockEntity.java +++ /dev/null @@ -1,12 +0,0 @@ -package jingy.jineric.block.entity.chests; - -import jingy.jineric.block.entity.JinericChestBlockEntity; -import jingy.jineric.block.enums.JinericChestType; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; - -public class SpruceChestBlockEntity extends JinericChestBlockEntity { - public SpruceChestBlockEntity(BlockPos blockPos, BlockState blockState) { - super(JinericChestType.SPRUCE, blockPos, blockState); - } -} diff --git a/src/main/java/jingy/jineric/block/entity/chests/WarpedChestBlockEntity.java b/src/main/java/jingy/jineric/block/entity/chests/WarpedChestBlockEntity.java deleted file mode 100644 index ef17068d..00000000 --- a/src/main/java/jingy/jineric/block/entity/chests/WarpedChestBlockEntity.java +++ /dev/null @@ -1,12 +0,0 @@ -package jingy.jineric.block.entity.chests; - -import jingy.jineric.block.entity.JinericChestBlockEntity; -import jingy.jineric.block.enums.JinericChestType; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; - -public class WarpedChestBlockEntity extends JinericChestBlockEntity { - public WarpedChestBlockEntity(BlockPos blockPos, BlockState blockState) { - super(JinericChestType.WARPED, blockPos, blockState); - } -} diff --git a/src/main/java/jingy/jineric/block/enums/JinericChestType.java b/src/main/java/jingy/jineric/block/enums/JinericChestType.java index ec6af1d7..65d5816d 100644 --- a/src/main/java/jingy/jineric/block/enums/JinericChestType.java +++ b/src/main/java/jingy/jineric/block/enums/JinericChestType.java @@ -1,19 +1,15 @@ package jingy.jineric.block.enums; import jingy.jineric.base.JinericMain; -import jingy.jineric.registry.JinericBlockEntityType; -import net.minecraft.block.BlockState; -import net.minecraft.block.entity.BlockEntityType; -import net.minecraft.block.entity.ChestBlockEntity; import net.minecraft.util.Identifier; -import net.minecraft.util.math.BlockPos; public enum JinericChestType { ACACIA(27, 9, new Identifier(JinericMain.MOD_ID, "entity/chest/acacia_chest"), new Identifier(JinericMain.MOD_ID, "entity/chest/acacia_left"), - new Identifier(JinericMain.MOD_ID, "entity/chest/acacia_right")), + new Identifier(JinericMain.MOD_ID, "entity/chest/acacia_right") + ), BIRCH(27, 9, new Identifier(JinericMain.MOD_ID, "entity/chest/birch_chest"), @@ -74,35 +70,35 @@ public enum JinericChestType { this.textureRight = null; } - public int getRowCount() { - return this.size / this.rowLength; - } - - public ChestBlockEntity getEntity(BlockPos pos, BlockState state) { - return switch (this) { - case ACACIA -> JinericBlockEntityType.ACACIA_CHEST.instantiate(pos, state); - case BIRCH -> JinericBlockEntityType.BIRCH_CHEST.instantiate(pos, state); - case CRIMSON -> JinericBlockEntityType.CRIMSON_CHEST.instantiate(pos, state); - case DARK_OAK -> JinericBlockEntityType.DARK_OAK_CHEST.instantiate(pos, state); - case JUNGLE -> JinericBlockEntityType.JUNGLE_CHEST.instantiate(pos, state); - case SPRUCE -> JinericBlockEntityType.SPRUCE_CHEST.instantiate(pos, state); - case WARPED -> JinericBlockEntityType.WARPED_CHEST.instantiate(pos, state); - case MANGROVE -> JinericBlockEntityType.MANGROVE_CHEST.instantiate(pos, state); - case SHULKER -> JinericBlockEntityType.SHULKER_CHEST.instantiate(pos, state); - }; - } - - public BlockEntityType getBlockEntityType() { - return switch (this) { - case ACACIA -> JinericBlockEntityType.ACACIA_CHEST; - case BIRCH -> JinericBlockEntityType.BIRCH_CHEST; - case CRIMSON -> JinericBlockEntityType.CRIMSON_CHEST; - case DARK_OAK -> JinericBlockEntityType.DARK_OAK_CHEST; - case JUNGLE -> JinericBlockEntityType.JUNGLE_CHEST; - case SPRUCE -> JinericBlockEntityType.SPRUCE_CHEST; - case WARPED -> JinericBlockEntityType.WARPED_CHEST; - case MANGROVE -> JinericBlockEntityType.MANGROVE_CHEST; - case SHULKER -> JinericBlockEntityType.SHULKER_CHEST; - }; - } +// public int getRowCount() { +// return this.size / this.rowLength; +// } + +// public ChestBlockEntity getEntity(BlockPos pos, BlockState state) { +// return switch (this) { +// case ACACIA -> JinericBlockEntityType.ACACIA_CHEST.instantiate(pos, state); +// case BIRCH -> JinericBlockEntityType.BIRCH_CHEST.instantiate(pos, state); +// case CRIMSON -> JinericBlockEntityType.CRIMSON_CHEST.instantiate(pos, state); +// case DARK_OAK -> JinericBlockEntityType.DARK_OAK_CHEST.instantiate(pos, state); +// case JUNGLE -> JinericBlockEntityType.JUNGLE_CHEST.instantiate(pos, state); +// case SPRUCE -> JinericBlockEntityType.SPRUCE_CHEST.instantiate(pos, state); +// case WARPED -> JinericBlockEntityType.WARPED_CHEST.instantiate(pos, state); +// case MANGROVE -> JinericBlockEntityType.MANGROVE_CHEST.instantiate(pos, state); +// case SHULKER -> JinericBlockEntityType.SHULKER_CHEST.instantiate(pos, state); +// }; +// } + +// public BlockEntityType getBlockEntityType() { +// return switch (this) { +// case ACACIA -> JinericBlockEntityType.ACACIA_CHEST; +// case BIRCH -> JinericBlockEntityType.BIRCH_CHEST; +// case CRIMSON -> JinericBlockEntityType.CRIMSON_CHEST; +// case DARK_OAK -> JinericBlockEntityType.DARK_OAK_CHEST; +// case JUNGLE -> JinericBlockEntityType.JUNGLE_CHEST; +// case SPRUCE -> JinericBlockEntityType.SPRUCE_CHEST; +// case WARPED -> JinericBlockEntityType.WARPED_CHEST; +// case MANGROVE -> JinericBlockEntityType.MANGROVE_CHEST; +// case SHULKER -> JinericBlockEntityType.SHULKER_CHEST; +// }; +// } } diff --git a/src/main/java/jingy/jineric/client/render/JinericTextureRenderLayers.java b/src/main/java/jingy/jineric/client/render/JinericTextureRenderLayers.java index f6b270a9..9c925833 100644 --- a/src/main/java/jingy/jineric/client/render/JinericTextureRenderLayers.java +++ b/src/main/java/jingy/jineric/client/render/JinericTextureRenderLayers.java @@ -1,8 +1,9 @@ package jingy.jineric.client.render; import jingy.jineric.base.JinericMain; +import jingy.jineric.block.entity.JinericChestBlockEntity; import jingy.jineric.block.entity.ShulkerChestBlockEntity; -import jingy.jineric.block.entity.chests.*; +import net.minecraft.block.WoodType; import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.enums.ChestType; import net.minecraft.client.render.TexturedRenderLayers; @@ -11,75 +12,73 @@ public class JinericTextureRenderLayers extends TexturedRenderLayers { - public static final SpriteIdentifier ACACIA_CHEST = getChestTextureId("acacia_chest"); - public static final SpriteIdentifier ACACIA_CHEST_LEFT = getChestTextureId("acacia_left"); - public static final SpriteIdentifier ACACIA_CHEST_RIGHT = getChestTextureId("acacia_right"); - public static final SpriteIdentifier BOREAL_CHEST = getChestTextureId("boreal_chest"); - public static final SpriteIdentifier BOREAL_CHEST_LEFT = getChestTextureId("boreal_left"); - public static final SpriteIdentifier BOREAL_CHEST_RIGHT = getChestTextureId("boreal_right"); - public static final SpriteIdentifier BIRCH_CHEST = getChestTextureId("birch_chest"); - public static final SpriteIdentifier BIRCH_CHEST_LEFT = getChestTextureId("birch_left"); - public static final SpriteIdentifier BIRCH_CHEST_RIGHT = getChestTextureId("birch_right"); - public static final SpriteIdentifier CRIMSON_CHEST = getChestTextureId("crimson_chest"); - public static final SpriteIdentifier CRIMSON_CHEST_LEFT = getChestTextureId("crimson_left"); - public static final SpriteIdentifier CRIMSON_CHEST_RIGHT = getChestTextureId("crimson_right"); - public static final SpriteIdentifier DARK_OAK_CHEST = getChestTextureId("dark_oak_chest"); - public static final SpriteIdentifier DARK_OAK_CHEST_LEFT = getChestTextureId("dark_oak_left"); - public static final SpriteIdentifier DARK_OAK_CHEST_RIGHT = getChestTextureId("dark_oak_right"); - public static final SpriteIdentifier JUNGLE_CHEST = getChestTextureId("jungle_chest"); - public static final SpriteIdentifier JUNGLE_CHEST_LEFT = getChestTextureId("jungle_left"); - public static final SpriteIdentifier JUNGLE_CHEST_RIGHT = getChestTextureId("jungle_right"); - public static final SpriteIdentifier SHULKER = getChestTextureId("shulker_chest"); - public static final SpriteIdentifier SPRUCE_CHEST = getChestTextureId("spruce_chest"); - public static final SpriteIdentifier SPRUCE_CHEST_LEFT = getChestTextureId("spruce_left"); - public static final SpriteIdentifier SPRUCE_CHEST_RIGHT = getChestTextureId("spruce_right"); - public static final SpriteIdentifier WARPED_CHEST = getChestTextureId("warped_chest"); - public static final SpriteIdentifier WARPED_CHEST_LEFT = getChestTextureId("warped_left"); - public static final SpriteIdentifier WARPED_CHEST_RIGHT = getChestTextureId("warped_right"); - public static final SpriteIdentifier MANGROVE_CHEST = getChestTextureId("mangrove_chest"); - public static final SpriteIdentifier MANGROVE_CHEST_LEFT = getChestTextureId("mangrove_left"); - public static final SpriteIdentifier MANGROVE_CHEST_RIGHT = getChestTextureId("mangrove_right"); - - private static SpriteIdentifier getChestTextureId(String variant) { + public static final SpriteIdentifier ACACIA_CHEST = createChestTextureId("acacia_chest"); + public static final SpriteIdentifier ACACIA_CHEST_LEFT = createChestTextureId("acacia_left"); + public static final SpriteIdentifier ACACIA_CHEST_RIGHT = createChestTextureId("acacia_right"); + public static final SpriteIdentifier BOREAL_CHEST = createChestTextureId("boreal_chest"); + public static final SpriteIdentifier BOREAL_CHEST_LEFT = createChestTextureId("boreal_left"); + public static final SpriteIdentifier BOREAL_CHEST_RIGHT = createChestTextureId("boreal_right"); + public static final SpriteIdentifier BIRCH_CHEST = createChestTextureId("birch_chest"); + public static final SpriteIdentifier BIRCH_CHEST_LEFT = createChestTextureId("birch_left"); + public static final SpriteIdentifier BIRCH_CHEST_RIGHT = createChestTextureId("birch_right"); + public static final SpriteIdentifier CRIMSON_CHEST = createChestTextureId("crimson_chest"); + public static final SpriteIdentifier CRIMSON_CHEST_LEFT = createChestTextureId("crimson_left"); + public static final SpriteIdentifier CRIMSON_CHEST_RIGHT = createChestTextureId("crimson_right"); + public static final SpriteIdentifier DARK_OAK_CHEST = createChestTextureId("dark_oak_chest"); + public static final SpriteIdentifier DARK_OAK_CHEST_LEFT = createChestTextureId("dark_oak_left"); + public static final SpriteIdentifier DARK_OAK_CHEST_RIGHT = createChestTextureId("dark_oak_right"); + public static final SpriteIdentifier JUNGLE_CHEST = createChestTextureId("jungle_chest"); + public static final SpriteIdentifier JUNGLE_CHEST_LEFT = createChestTextureId("jungle_left"); + public static final SpriteIdentifier JUNGLE_CHEST_RIGHT = createChestTextureId("jungle_right"); + public static final SpriteIdentifier SHULKER = createChestTextureId("shulker_chest"); + public static final SpriteIdentifier SPRUCE_CHEST = createChestTextureId("spruce_chest"); + public static final SpriteIdentifier SPRUCE_CHEST_LEFT = createChestTextureId("spruce_left"); + public static final SpriteIdentifier SPRUCE_CHEST_RIGHT = createChestTextureId("spruce_right"); + public static final SpriteIdentifier WARPED_CHEST = createChestTextureId("warped_chest"); + public static final SpriteIdentifier WARPED_CHEST_LEFT = createChestTextureId("warped_left"); + public static final SpriteIdentifier WARPED_CHEST_RIGHT = createChestTextureId("warped_right"); + public static final SpriteIdentifier MANGROVE_CHEST = createChestTextureId("mangrove_chest"); + public static final SpriteIdentifier MANGROVE_CHEST_LEFT = createChestTextureId("mangrove_left"); + public static final SpriteIdentifier MANGROVE_CHEST_RIGHT = createChestTextureId("mangrove_right"); + + private static SpriteIdentifier createChestTextureId(String variant) { return new SpriteIdentifier(CHEST_ATLAS_TEXTURE, new Identifier(JinericMain.MOD_ID, "entity/chest/" + variant)); } - public static SpriteIdentifier getChestTexture(BlockEntity blockEntity, ChestType chestType, boolean christmas) { - if (blockEntity instanceof ShulkerChestBlockEntity) { - return SHULKER; - } else if (christmas) { + public static SpriteIdentifier getChestTexture(BlockEntity blockEntity, ChestType chestType, boolean christmas, WoodType woodType) { + if (christmas) { return getChestTexture(chestType, CHRISTMAS, CHRISTMAS_LEFT, CHRISTMAS_RIGHT); - - } else if (blockEntity instanceof AcaciaChestBlockEntity) { - return getChestTexture(chestType, ACACIA_CHEST, ACACIA_CHEST_LEFT, ACACIA_CHEST_RIGHT); - - } else if (blockEntity instanceof BirchChestBlockEntity) { - return getChestTexture(chestType, BIRCH_CHEST, BIRCH_CHEST_LEFT, BIRCH_CHEST_RIGHT); - - } else if (blockEntity instanceof BorealChestBlockEntity) { - return getChestTexture(chestType, BOREAL_CHEST, BOREAL_CHEST_LEFT, BOREAL_CHEST_RIGHT); - - } else if (blockEntity instanceof CrimsonChestBlockEntity) { - return getChestTexture(chestType, CRIMSON_CHEST, CRIMSON_CHEST_LEFT, CRIMSON_CHEST_RIGHT); - - } else if (blockEntity instanceof DarkOakChestBlockEntity) { - return getChestTexture(chestType, DARK_OAK_CHEST, DARK_OAK_CHEST_LEFT, DARK_OAK_CHEST_RIGHT); - - } else if (blockEntity instanceof JungleChestBlockEntity) { - return getChestTexture(chestType, JUNGLE_CHEST, JUNGLE_CHEST_LEFT, JUNGLE_CHEST_RIGHT); - - } else if (blockEntity instanceof SpruceChestBlockEntity) { - return getChestTexture(chestType, SPRUCE_CHEST, SPRUCE_CHEST_LEFT, SPRUCE_CHEST_RIGHT); - - } else if (blockEntity instanceof WarpedChestBlockEntity) { - return getChestTexture(chestType, WARPED_CHEST, WARPED_CHEST_LEFT, WARPED_CHEST_RIGHT); - - } else if (blockEntity instanceof MangroveChestBlockEntity) { - return getChestTexture(chestType, MANGROVE_CHEST, MANGROVE_CHEST_LEFT, MANGROVE_CHEST_RIGHT); - - } else { - return getChestTexture(chestType, NORMAL, NORMAL_LEFT, NORMAL_RIGHT); } + else if (blockEntity instanceof ShulkerChestBlockEntity) { + return SHULKER; + } + else if (blockEntity instanceof JinericChestBlockEntity) { + if (woodType == WoodType.ACACIA) { + return getChestTexture(chestType, ACACIA_CHEST, ACACIA_CHEST_LEFT, ACACIA_CHEST_RIGHT); + } + else if (woodType == WoodType.BIRCH) { + return getChestTexture(chestType, BIRCH_CHEST, BIRCH_CHEST_LEFT, BIRCH_CHEST_RIGHT); + } + else if (woodType == WoodType.CRIMSON) { + return getChestTexture(chestType, CRIMSON_CHEST, CRIMSON_CHEST_LEFT, CRIMSON_CHEST_RIGHT); + } + else if (woodType == WoodType.DARK_OAK) { + return getChestTexture(chestType, DARK_OAK_CHEST, DARK_OAK_CHEST_LEFT, DARK_OAK_CHEST_RIGHT); + } + else if (woodType == WoodType.JUNGLE) { + return getChestTexture(chestType, JUNGLE_CHEST, JUNGLE_CHEST_LEFT, JUNGLE_CHEST_RIGHT); + } + else if (woodType == WoodType.SPRUCE) { + return getChestTexture(chestType, SPRUCE_CHEST, SPRUCE_CHEST_LEFT, SPRUCE_CHEST_RIGHT); + } + else if (woodType == WoodType.WARPED) { + return getChestTexture(chestType, WARPED_CHEST, WARPED_CHEST_LEFT, WARPED_CHEST_RIGHT); + } + else if (woodType == WoodType.MANGROVE) { + return getChestTexture(chestType, MANGROVE_CHEST, MANGROVE_CHEST_LEFT, MANGROVE_CHEST_RIGHT); + } + } + return null; } public static SpriteIdentifier getChestTexture(ChestType type, SpriteIdentifier single, SpriteIdentifier left, SpriteIdentifier right) { diff --git a/src/main/java/jingy/jineric/item/JinericItemGroups.java b/src/main/java/jingy/jineric/item/JinericItemGroups.java index cc2ceebd..9b13c663 100644 --- a/src/main/java/jingy/jineric/item/JinericItemGroups.java +++ b/src/main/java/jingy/jineric/item/JinericItemGroups.java @@ -227,7 +227,7 @@ public class JinericItemGroups { entries.add(JinericItems.TUFF_TILE_SLAB); entries.add(JinericItems.TUFF_TILE_STAIRS); entries.add(JinericItems.TUFF_TILE_WALL); - entries.add(JinericItems.SHULKER_CHEST); +// entries.add(JinericItems.SHULKER_CHEST); entries.add(JinericItems.GOLDEN_POTATO); entries.add(JinericItems.GOLDEN_SWEET_BERRIES); entries.add(JinericItems.GOLDEN_BEETROOT); diff --git a/src/main/java/jingy/jineric/item/JinericItems.java b/src/main/java/jingy/jineric/item/JinericItems.java index 5cbc5fc3..9976a373 100644 --- a/src/main/java/jingy/jineric/item/JinericItems.java +++ b/src/main/java/jingy/jineric/item/JinericItems.java @@ -188,10 +188,10 @@ public class JinericItems { public static final Item CRIMSON_BOOKSHELF = register("crimson_bookshelf", new BlockItem(JinericBlocks.CRIMSON_BOOKSHELF, new FabricItemSettings())); public static final Item WARPED_BOOKSHELF = register("warped_bookshelf", new BlockItem(JinericBlocks.WARPED_BOOKSHELF, new FabricItemSettings())); //CHESTS - public static final Item SPRUCE_CHEST = register("spruce_chest", new BlockItem(JinericBlocks.SPRUCE_CHEST, new FabricItemSettings())); + public static final Item ACACIA_CHEST = register("acacia_chest", new BlockItem(JinericBlocks.ACACIA_CHEST, new FabricItemSettings())); public static final Item BIRCH_CHEST = register("birch_chest", new BlockItem(JinericBlocks.BIRCH_CHEST, new FabricItemSettings())); + public static final Item SPRUCE_CHEST = register("spruce_chest", new BlockItem(JinericBlocks.SPRUCE_CHEST, new FabricItemSettings())); public static final Item JUNGLE_CHEST = register("jungle_chest", new BlockItem(JinericBlocks.JUNGLE_CHEST, new FabricItemSettings())); - public static final Item ACACIA_CHEST = register("acacia_chest", new BlockItem(JinericBlocks.ACACIA_CHEST, new FabricItemSettings())); public static final Item DARK_OAK_CHEST = register("dark_oak_chest", new BlockItem(JinericBlocks.DARK_OAK_CHEST, new FabricItemSettings())); public static final Item MANGROVE_CHEST = register("mangrove_chest", new BlockItem(JinericBlocks.MANGROVE_CHEST, new FabricItemSettings())); public static final Item CRIMSON_CHEST = register("crimson_chest", new BlockItem(JinericBlocks.CRIMSON_CHEST, new FabricItemSettings())); @@ -302,7 +302,7 @@ public class JinericItems { // public static final Item SMOOTH_CALCITE_WALL = register("smooth_calcite_wall", new BlockItem(JinericBlocks.SMOOTH_CALCITE_WALL, new FabricItemSettings())); //MISC - public static final Item SHULKER_CHEST = register("shulker_chest", new BlockItem(JinericBlocks.SHULKER_CHEST, new FabricItemSettings())); +// public static final Item SHULKER_CHEST = register("shulker_chest", new BlockItem(JinericBlocks.SHULKER_CHEST, new FabricItemSettings())); public static final Item GOLDEN_POTATO = register("golden_potato", new Item(new FabricItemSettings().food(new FoodComponent.Builder().hunger(6).saturationModifier(14.4f).build()))); public static final Item GOLDEN_SWEET_BERRIES = register("golden_sweet_berries", new Item(new FabricItemSettings().food(new FoodComponent.Builder().hunger(5).saturationModifier(8f).build()))); public static final Item GOLDEN_BEETROOT = register("golden_beetroot", new Item(new FabricItemSettings().food(new FoodComponent.Builder().hunger(4).saturationModifier(5f).build()))); diff --git a/src/main/java/jingy/jineric/mixin/ChestBlockEntityRendererMixin.java b/src/main/java/jingy/jineric/mixin/ChestBlockEntityRendererMixin.java index b014c0c0..15ff984c 100644 --- a/src/main/java/jingy/jineric/mixin/ChestBlockEntityRendererMixin.java +++ b/src/main/java/jingy/jineric/mixin/ChestBlockEntityRendererMixin.java @@ -2,8 +2,11 @@ import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import jingy.jineric.block.JinericChestBlock; import jingy.jineric.block.entity.JinericChestBlockEntity; import jingy.jineric.client.render.JinericTextureRenderLayers; +import net.minecraft.block.BlockState; +import net.minecraft.block.WoodType; import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.enums.ChestType; import net.minecraft.client.render.block.entity.ChestBlockEntityRenderer; @@ -20,8 +23,10 @@ public abstract class ChestBlockEntityRendererMixin { target = "Lnet/minecraft/client/render/TexturedRenderLayers;getChestTextureId(Lnet/minecraft/block/entity/BlockEntity;Lnet/minecraft/block/enums/ChestType;Z)Lnet/minecraft/client/util/SpriteIdentifier;") ) private SpriteIdentifier jineric$getJinericChestTexture(BlockEntity blockEntity, ChestType type, boolean christmas, Operation original) { + BlockState blockState = blockEntity.getCachedState(); + WoodType woodType = JinericChestBlock.getWoodType(blockState.getBlock()); if (blockEntity instanceof JinericChestBlockEntity) { - return JinericTextureRenderLayers.getChestTexture(blockEntity, type, christmas); + return JinericTextureRenderLayers.getChestTexture(blockEntity, type, christmas, woodType); } else { return original.call(blockEntity, type, christmas); } diff --git a/src/main/java/jingy/jineric/registry/JinericBlockEntityRenderer.java b/src/main/java/jingy/jineric/registry/JinericBlockEntityRenderer.java index 41f548de..c199b943 100644 --- a/src/main/java/jingy/jineric/registry/JinericBlockEntityRenderer.java +++ b/src/main/java/jingy/jineric/registry/JinericBlockEntityRenderer.java @@ -8,16 +8,8 @@ public class JinericBlockEntityRenderer { public static void register() { BlockEntityRendererFactories.register(JinericBlockEntityType.REDSTONE_CAMPFIRE, RedstoneCampfireBlockEntityRenderer::new); - BlockEntityRendererFactories.register(JinericBlockEntityType.ACACIA_CHEST, ChestBlockEntityRenderer::new); - BlockEntityRendererFactories.register(JinericBlockEntityType.BIRCH_CHEST, ChestBlockEntityRenderer::new); -// BlockEntityRendererRegistry.register(JinericBlockEntityType.BOREAL_CHEST, GenericChestBlockEntityRenderer::new); - BlockEntityRendererFactories.register(JinericBlockEntityType.CRIMSON_CHEST, ChestBlockEntityRenderer::new); - BlockEntityRendererFactories.register(JinericBlockEntityType.DARK_OAK_CHEST, ChestBlockEntityRenderer::new); - BlockEntityRendererFactories.register(JinericBlockEntityType.JUNGLE_CHEST, ChestBlockEntityRenderer::new); - BlockEntityRendererFactories.register(JinericBlockEntityType.SPRUCE_CHEST, ChestBlockEntityRenderer::new); - BlockEntityRendererFactories.register(JinericBlockEntityType.WARPED_CHEST, ChestBlockEntityRenderer::new); - BlockEntityRendererFactories.register(JinericBlockEntityType.MANGROVE_CHEST, ChestBlockEntityRenderer::new); - BlockEntityRendererFactories.register(JinericBlockEntityType.SHULKER_CHEST, ChestBlockEntityRenderer::new); + BlockEntityRendererFactories.register(JinericBlockEntityType.JINERIC_CHEST, ChestBlockEntityRenderer::new); +// BlockEntityRendererRegistry.register(JinericBlockEntityType.BOREAL_CHEST, GenericChestBlockEntityRenderer::new); BlockEntityRendererFactories.register(JinericBlockEntityType.REDSTONE_CAMPFIRE, RedstoneCampfireBlockEntityRenderer::new); } } diff --git a/src/main/java/jingy/jineric/registry/JinericBlockEntityType.java b/src/main/java/jingy/jineric/registry/JinericBlockEntityType.java index 999e8c22..27e296ed 100644 --- a/src/main/java/jingy/jineric/registry/JinericBlockEntityType.java +++ b/src/main/java/jingy/jineric/registry/JinericBlockEntityType.java @@ -2,68 +2,42 @@ import jingy.jineric.base.JinericMain; import jingy.jineric.block.JinericBlocks; +import jingy.jineric.block.entity.JinericChestBlockEntity; import jingy.jineric.block.entity.RedstoneCampfireBlockEntity; import jingy.jineric.block.entity.RefineryBlockEntity; -import jingy.jineric.block.entity.ShulkerChestBlockEntity; -import jingy.jineric.block.entity.chests.*; import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder; +import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntityType; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; import net.minecraft.util.Identifier; -public class JinericBlockEntityType { - //CHESTS - public static final BlockEntityType ACACIA_CHEST = - FabricBlockEntityTypeBuilder.create(AcaciaChestBlockEntity::new, JinericBlocks.ACACIA_CHEST).build(null); - - public static final BlockEntityType BIRCH_CHEST = - FabricBlockEntityTypeBuilder.create(BirchChestBlockEntity::new, JinericBlocks.BIRCH_CHEST).build(null); - -// public static final BlockEntityType BOREAL_CHEST = -// FabricBlockEntityTypeBuilder.create(BorealChestBlockEntity::new, JinericBlocks.BOREAL_CHEST).build(null); - - public static final BlockEntityType CRIMSON_CHEST = - FabricBlockEntityTypeBuilder.create(CrimsonChestBlockEntity::new, JinericBlocks.CRIMSON_CHEST).build(null); - - public static final BlockEntityType DARK_OAK_CHEST = - FabricBlockEntityTypeBuilder.create(DarkOakChestBlockEntity::new, JinericBlocks.DARK_OAK_CHEST).build(null); - - public static final BlockEntityType JUNGLE_CHEST = - FabricBlockEntityTypeBuilder.create(JungleChestBlockEntity::new, JinericBlocks.JUNGLE_CHEST).build(null); - - public static final BlockEntityType SPRUCE_CHEST = - FabricBlockEntityTypeBuilder.create(SpruceChestBlockEntity::new, JinericBlocks.SPRUCE_CHEST).build(null); - - public static final BlockEntityType WARPED_CHEST = - FabricBlockEntityTypeBuilder.create(WarpedChestBlockEntity::new, JinericBlocks.WARPED_CHEST).build(null); - - public static final BlockEntityType MANGROVE_CHEST = - FabricBlockEntityTypeBuilder.create(MangroveChestBlockEntity::new, JinericBlocks.MANGROVE_CHEST).build(null); - - public static final BlockEntityType SHULKER_CHEST = - FabricBlockEntityTypeBuilder.create(ShulkerChestBlockEntity::new, JinericBlocks.SHULKER_CHEST).build(null); - +public class JinericBlockEntityType { + + public static final BlockEntityType JINERIC_CHEST = + FabricBlockEntityTypeBuilder.create( + JinericChestBlockEntity::new, + JinericBlocks.ACACIA_CHEST, + JinericBlocks.BIRCH_CHEST, + JinericBlocks.BIRCH_CHEST, + JinericBlocks.CRIMSON_CHEST, + JinericBlocks.DARK_OAK_CHEST, + JinericBlocks.JUNGLE_CHEST, + JinericBlocks.SPRUCE_CHEST, + JinericBlocks.WARPED_CHEST, + JinericBlocks.MANGROVE_CHEST + ).build(); public static final BlockEntityType REFINERY = - FabricBlockEntityTypeBuilder.create(RefineryBlockEntity::new, JinericBlocks.REFINERY).build(null); + FabricBlockEntityTypeBuilder.create(RefineryBlockEntity::new, JinericBlocks.REFINERY).build(); public static final BlockEntityType REDSTONE_CAMPFIRE = - FabricBlockEntityTypeBuilder.create(RedstoneCampfireBlockEntity::new, JinericBlocks.REDSTONE_CAMPFIRE).build(null); + FabricBlockEntityTypeBuilder.create(RedstoneCampfireBlockEntity::new, JinericBlocks.REDSTONE_CAMPFIRE).build(); public static void registerBlockEntities() { - //CHESTS - Registry.register(Registries.BLOCK_ENTITY_TYPE, new Identifier(JinericMain.MOD_ID, "acacia_chest"), ACACIA_CHEST); - Registry.register(Registries.BLOCK_ENTITY_TYPE, new Identifier(JinericMain.MOD_ID, "birch_chest"), BIRCH_CHEST); + Registry.register(Registries.BLOCK_ENTITY_TYPE, new Identifier(JinericMain.MOD_ID, "jineric_chest"), JINERIC_CHEST); // Registry.register(Registries.BLOCK_ENTITY_TYPE, new Identifier(JinericMain.MOD_ID, "boreal_chest"), BOREAL_CHEST); - Registry.register(Registries.BLOCK_ENTITY_TYPE, new Identifier(JinericMain.MOD_ID, "crimson_chest"), CRIMSON_CHEST); - Registry.register(Registries.BLOCK_ENTITY_TYPE, new Identifier(JinericMain.MOD_ID, "dark_oak_chest"), DARK_OAK_CHEST); - Registry.register(Registries.BLOCK_ENTITY_TYPE, new Identifier(JinericMain.MOD_ID, "jungle_chest"), JUNGLE_CHEST); - Registry.register(Registries.BLOCK_ENTITY_TYPE, new Identifier(JinericMain.MOD_ID, "spruce_chest"), SPRUCE_CHEST); - Registry.register(Registries.BLOCK_ENTITY_TYPE, new Identifier(JinericMain.MOD_ID, "warped_chest"), WARPED_CHEST); - Registry.register(Registries.BLOCK_ENTITY_TYPE, new Identifier(JinericMain.MOD_ID, "mangrove_chest"), MANGROVE_CHEST); - Registry.register(Registries.BLOCK_ENTITY_TYPE, new Identifier(JinericMain.MOD_ID, "shulker_chest"), SHULKER_CHEST); - +// Registry.register(Registries.BLOCK_ENTITY_TYPE, new Identifier(JinericMain.MOD_ID, "shulker_chest"), SHULKER_CHEST); Registry.register(Registries.BLOCK_ENTITY_TYPE, new Identifier(JinericMain.MOD_ID, "refinery"), REFINERY); Registry.register(Registries.BLOCK_ENTITY_TYPE, new Identifier(JinericMain.MOD_ID, "campfire"), REDSTONE_CAMPFIRE); }