diff --git a/src/main/java/net/ludocrypt/carvepump/blocks/CarvableBlock.java b/src/main/java/net/ludocrypt/carvepump/blocks/CarvableBlock.java index 3c1b8e1..40ca11f 100644 --- a/src/main/java/net/ludocrypt/carvepump/blocks/CarvableBlock.java +++ b/src/main/java/net/ludocrypt/carvepump/blocks/CarvableBlock.java @@ -12,6 +12,7 @@ import net.minecraft.item.ItemPlacementContext; import net.minecraft.state.StateManager; import net.minecraft.state.property.DirectionProperty; +import net.minecraft.util.Identifier; import net.minecraft.util.math.Direction; import net.minecraft.world.BlockView; @@ -49,4 +50,8 @@ public Block getCarvingBlock() { return Blocks.PUMPKIN; } + public Identifier getRenderId() { + return new Identifier("carvepump", "textures/entity/pumpkin_halo_colors.png"); + } + } diff --git a/src/main/java/net/ludocrypt/carvepump/blocks/CarvableMelonBlock.java b/src/main/java/net/ludocrypt/carvepump/blocks/CarvableMelonBlock.java index 13af9eb..06e8de4 100644 --- a/src/main/java/net/ludocrypt/carvepump/blocks/CarvableMelonBlock.java +++ b/src/main/java/net/ludocrypt/carvepump/blocks/CarvableMelonBlock.java @@ -12,6 +12,7 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundTag; +import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; import net.minecraft.world.BlockView; import net.minecraft.world.World; @@ -74,4 +75,9 @@ public Block getCarvingBlock() { return Blocks.MELON; } + @Override + public Identifier getRenderId() { + return new Identifier("carvepump", "textures/entity/melon_halo_colors.png"); + } + } diff --git a/src/main/java/net/ludocrypt/carvepump/blocks/CarvablePumpkinBlock.java b/src/main/java/net/ludocrypt/carvepump/blocks/CarvablePumpkinBlock.java index 246a27d..ca2d4a0 100644 --- a/src/main/java/net/ludocrypt/carvepump/blocks/CarvablePumpkinBlock.java +++ b/src/main/java/net/ludocrypt/carvepump/blocks/CarvablePumpkinBlock.java @@ -25,6 +25,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.predicate.block.BlockStatePredicate; import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.util.Identifier; import net.minecraft.util.function.MaterialPredicate; import net.minecraft.util.math.BlockPos; import net.minecraft.world.BlockView; @@ -95,6 +96,11 @@ public Block getCarvingBlock() { return Blocks.PUMPKIN; } + @Override + public Identifier getRenderId() { + return new Identifier("carvepump", "textures/entity/pumpkin_halo_colors.png"); + } + // Pumpkin Spawning @Override diff --git a/src/main/java/net/ludocrypt/carvepump/blocks/UncarvableBlock.java b/src/main/java/net/ludocrypt/carvepump/blocks/UncarvableBlock.java index 7ed4d74..f5c51b2 100644 --- a/src/main/java/net/ludocrypt/carvepump/blocks/UncarvableBlock.java +++ b/src/main/java/net/ludocrypt/carvepump/blocks/UncarvableBlock.java @@ -12,6 +12,7 @@ import net.minecraft.item.ItemPlacementContext; import net.minecraft.state.StateManager; import net.minecraft.state.property.DirectionProperty; +import net.minecraft.util.Identifier; import net.minecraft.util.math.Direction; import net.minecraft.world.BlockView; @@ -49,4 +50,8 @@ public Block getCarvingBlock() { return Blocks.PUMPKIN; } + public Identifier getRenderId() { + return new Identifier("carvepump", "textures/entity/jack_o_lantern_halo_colors.png"); + } + } diff --git a/src/main/java/net/ludocrypt/carvepump/blocks/UncarvableMelonBlock.java b/src/main/java/net/ludocrypt/carvepump/blocks/UncarvableMelonBlock.java index 6975b97..6f215b0 100644 --- a/src/main/java/net/ludocrypt/carvepump/blocks/UncarvableMelonBlock.java +++ b/src/main/java/net/ludocrypt/carvepump/blocks/UncarvableMelonBlock.java @@ -13,6 +13,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.nbt.CompoundTag; +import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; import net.minecraft.world.BlockView; import net.minecraft.world.World; @@ -93,4 +94,9 @@ public Block getCarvingBlock() { return Blocks.MELON; } + @Override + public Identifier getRenderId() { + return new Identifier("carvepump", "textures/entity/jack_o_melon_halo_colors.png"); + } + } diff --git a/src/main/java/net/ludocrypt/carvepump/blocks/UncarvablePumpkinBlock.java b/src/main/java/net/ludocrypt/carvepump/blocks/UncarvablePumpkinBlock.java index 8f5caa9..b2f6ff1 100644 --- a/src/main/java/net/ludocrypt/carvepump/blocks/UncarvablePumpkinBlock.java +++ b/src/main/java/net/ludocrypt/carvepump/blocks/UncarvablePumpkinBlock.java @@ -26,6 +26,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.predicate.block.BlockStatePredicate; import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.util.Identifier; import net.minecraft.util.function.MaterialPredicate; import net.minecraft.util.math.BlockPos; import net.minecraft.world.BlockView; @@ -114,6 +115,11 @@ public Block getCarvingBlock() { return Blocks.PUMPKIN; } + @Override + public Identifier getRenderId() { + return new Identifier("carvepump", "textures/entity/jack_o_lantern_halo_colors.png"); + } + // Pumpkin Spawning @Override diff --git a/src/main/java/net/ludocrypt/carvepump/client/render/block/entity/CarvedBlockEntityRenderer.java b/src/main/java/net/ludocrypt/carvepump/client/render/block/entity/CarvedBlockEntityRenderer.java index 1d77981..aa11bfd 100644 --- a/src/main/java/net/ludocrypt/carvepump/client/render/block/entity/CarvedBlockEntityRenderer.java +++ b/src/main/java/net/ludocrypt/carvepump/client/render/block/entity/CarvedBlockEntityRenderer.java @@ -2,7 +2,6 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.ludocrypt.carvepump.CarveMyPumpkin; import net.ludocrypt.carvepump.blocks.CarvableBlock; import net.ludocrypt.carvepump.blocks.UncarvableBlock; import net.ludocrypt.carvepump.blocks.entity.CarvedBlockEntity; @@ -26,13 +25,8 @@ @Environment(EnvType.CLIENT) public class CarvedBlockEntityRenderer extends BlockEntityRenderer { + private static final MinecraftClient client = MinecraftClient.getInstance(); - public static Identifier PUMPKIN_HALO = new Identifier("carvepump", "textures/entity/pumpkin_halo_colors.png"); - public static Identifier JACK_O_LANTERN_HALO = new Identifier("carvepump", - "textures/entity/jack_o_lantern_halo_colors.png"); - public static Identifier MELON_HALO = new Identifier("carvepump", "textures/entity/melon_halo_colors.png"); - public static Identifier JACK_O_MELON_HALO = new Identifier("carvepump", - "textures/entity/jack_o_melon_halo_colors.png"); public CarvedBlockEntityRenderer(BlockEntityRenderDispatcher blockEntityRenderDispatcher) { super(blockEntityRenderDispatcher); @@ -53,26 +47,20 @@ public void render(CarvedBlockEntity carvedBlockEntity, float f, MatrixStack mat MinecraftClient.getInstance().getItemRenderer().renderItem( new ItemStack(((CarvableBlock) block).getCarvingBlock()), ModelTransformation.Mode.NONE, lightAbove, OverlayTexture.DEFAULT_UV, matrixStack, vertexConsumerProvider); + + matrixStack.translate(-0.5, -0.5, -0.5); + + renderFace(carvedBlockEntity, ((CarvableBlock) block).getRenderId(), matrixStack, vertexConsumerProvider, + lightAbove, OverlayTexture.DEFAULT_UV); } else if (block instanceof UncarvableBlock) { MinecraftClient.getInstance().getItemRenderer().renderItem( new ItemStack(((UncarvableBlock) block).getCarvingBlock()), ModelTransformation.Mode.NONE, lightAbove, OverlayTexture.DEFAULT_UV, matrixStack, vertexConsumerProvider); - } - matrixStack.translate(-0.5, -0.5, -0.5); - - if (block == CarveMyPumpkin.CARVED_PUMPKIN) { - renderFace(carvedBlockEntity, PUMPKIN_HALO, matrixStack, vertexConsumerProvider, lightAbove, - OverlayTexture.DEFAULT_UV); - } else if (block == CarveMyPumpkin.JACK_O_LANTERN) { - renderFace(carvedBlockEntity, JACK_O_LANTERN_HALO, matrixStack, vertexConsumerProvider, lightAbove, - OverlayTexture.DEFAULT_UV); - } else if (block == CarveMyPumpkin.CARVED_MELON) { - renderFace(carvedBlockEntity, MELON_HALO, matrixStack, vertexConsumerProvider, lightAbove, - OverlayTexture.DEFAULT_UV); - } else if (block == CarveMyPumpkin.JACK_O_MELON) { - renderFace(carvedBlockEntity, JACK_O_MELON_HALO, matrixStack, vertexConsumerProvider, lightAbove, - OverlayTexture.DEFAULT_UV); + matrixStack.translate(-0.5, -0.5, -0.5); + + renderFace(carvedBlockEntity, ((UncarvableBlock) block).getRenderId(), matrixStack, vertexConsumerProvider, + lightAbove, OverlayTexture.DEFAULT_UV); } matrixStack.pop(); @@ -207,35 +195,22 @@ public static void renderInHand(ItemStack stack, ModelTransformation.Mode mode, dir = Direction.NORTH; break; } - - if (block == CarveMyPumpkin.CARVED_PUMPKIN) { - for (int x = 0; x < 16; x++) { - for (int y = 0; y < 16; y++) { - renderModel(x, y, carving, PUMPKIN_HALO, dir, matrixStack, vertexConsumerProvider, i, - j); - } - } - } else if (block == CarveMyPumpkin.JACK_O_LANTERN) { + if (block instanceof CarvableBlock) { for (int x = 0; x < 16; x++) { for (int y = 0; y < 16; y++) { - renderModel(x, y, carving, JACK_O_LANTERN_HALO, dir, matrixStack, + renderModel(x, y, carving, ((CarvableBlock) block).getRenderId(), dir, matrixStack, vertexConsumerProvider, i, j); } } - } else if (block == CarveMyPumpkin.CARVED_MELON) { - for (int x = 0; x < 16; x++) { - for (int y = 0; y < 16; y++) { - renderModel(x, y, carving, MELON_HALO, dir, matrixStack, vertexConsumerProvider, i, j); - } - } - } else if (block == CarveMyPumpkin.JACK_O_MELON) { + } else if (block instanceof UncarvableBlock) { for (int x = 0; x < 16; x++) { for (int y = 0; y < 16; y++) { - renderModel(x, y, carving, JACK_O_MELON_HALO, dir, matrixStack, vertexConsumerProvider, - i, j); + renderModel(x, y, carving, ((UncarvableBlock) block).getRenderId(), dir, matrixStack, + vertexConsumerProvider, i, j); } } } + } } } diff --git a/src/main/java/net/ludocrypt/carvepump/items/CarverItem.java b/src/main/java/net/ludocrypt/carvepump/items/CarverItem.java index 7ae742e..1a05211 100644 --- a/src/main/java/net/ludocrypt/carvepump/items/CarverItem.java +++ b/src/main/java/net/ludocrypt/carvepump/items/CarverItem.java @@ -98,7 +98,7 @@ public ActionResult useOnBlock(ItemUsageContext context) { })); } if (carvedPumpkinBlockEntity.isUncarved()) { - world.setBlockState(pos, Blocks.PUMPKIN.getDefaultState(), 2); + world.setBlockState(pos, ((CarvableBlock) block).getCarvingBlock().getDefaultState(), 2); } return ActionResult.SUCCESS; } else { diff --git a/src/main/resources/assets/carvepump/textures/entity/jack_o_melon_halo_colors.png b/src/main/resources/assets/carvepump/textures/entity/jack_o_melon_halo_colors.png index fb4ae99..0aa094f 100644 Binary files a/src/main/resources/assets/carvepump/textures/entity/jack_o_melon_halo_colors.png and b/src/main/resources/assets/carvepump/textures/entity/jack_o_melon_halo_colors.png differ diff --git a/src/main/resources/assets/carvepump/textures/entity/melon_halo_colors.png b/src/main/resources/assets/carvepump/textures/entity/melon_halo_colors.png index f81ee9f..f1739f6 100644 Binary files a/src/main/resources/assets/carvepump/textures/entity/melon_halo_colors.png and b/src/main/resources/assets/carvepump/textures/entity/melon_halo_colors.png differ