From c2306d7fa633e31abff280826c3146a0bb083f47 Mon Sep 17 00:00:00 2001 From: Motschen Date: Sat, 23 Jan 2021 19:58:36 +0100 Subject: [PATCH] Fix ClassCastExeption --- .../visualoverhaul/VisualOverhaulClient.java | 1 + .../renderer/FurnaceBlockEntityRenderer.java | 2 +- .../MixinAbstractFurnaceBlockEntity.java | 27 ++++++++++--------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/main/java/eu/midnightdust/visualoverhaul/VisualOverhaulClient.java b/src/main/java/eu/midnightdust/visualoverhaul/VisualOverhaulClient.java index d6708f1..f30d510 100644 --- a/src/main/java/eu/midnightdust/visualoverhaul/VisualOverhaulClient.java +++ b/src/main/java/eu/midnightdust/visualoverhaul/VisualOverhaulClient.java @@ -58,6 +58,7 @@ public void onInitializeClient() { } }); + ClientSidePacketRegistryImpl.INSTANCE.register(UPDATE_POTION_BOTTLES, (packetContext, attachedData) -> { BlockPos pos = attachedData.readBlockPos(); diff --git a/src/main/java/eu/midnightdust/visualoverhaul/block/renderer/FurnaceBlockEntityRenderer.java b/src/main/java/eu/midnightdust/visualoverhaul/block/renderer/FurnaceBlockEntityRenderer.java index 1053934..e956034 100644 --- a/src/main/java/eu/midnightdust/visualoverhaul/block/renderer/FurnaceBlockEntityRenderer.java +++ b/src/main/java/eu/midnightdust/visualoverhaul/block/renderer/FurnaceBlockEntityRenderer.java @@ -62,7 +62,7 @@ public FurnaceBlockEntityRenderer(BlockEntityRenderDispatcher blockEntityRenderD @Override public void render(FurnaceBlockEntity blockEntity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) { - if (VisualOverhaulClient.VO_CONFIG.furnace) { + if (VisualOverhaulClient.VO_CONFIG.furnace && blockEntity.getCachedState().getBlock().is(Blocks.FURNACE)) { BlockState blockState = blockEntity.getCachedState(); int lightAtBlock = WorldRenderer.getLightmapCoordinates(blockEntity.getWorld(), blockEntity.getPos().offset(blockState.get(AbstractFurnaceBlock.FACING))); ItemStack item1 = blockEntity.getStack(0); diff --git a/src/main/java/eu/midnightdust/visualoverhaul/mixin/MixinAbstractFurnaceBlockEntity.java b/src/main/java/eu/midnightdust/visualoverhaul/mixin/MixinAbstractFurnaceBlockEntity.java index 5f0ebcb..92a9f1c 100644 --- a/src/main/java/eu/midnightdust/visualoverhaul/mixin/MixinAbstractFurnaceBlockEntity.java +++ b/src/main/java/eu/midnightdust/visualoverhaul/mixin/MixinAbstractFurnaceBlockEntity.java @@ -4,6 +4,7 @@ import io.netty.buffer.Unpooled; import net.fabricmc.fabric.api.server.PlayerStream; import net.fabricmc.fabric.impl.networking.ServerSidePacketRegistryImpl; +import net.minecraft.block.Blocks; import net.minecraft.block.entity.*; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; @@ -31,19 +32,21 @@ private MixinAbstractFurnaceBlockEntity(BlockEntityType blockEntityType) { @Inject(at = @At("TAIL"), method = "tick") public void tick(CallbackInfo ci) { - if (!this.world.isClient && (invUpdate || world.getPlayers().size() == playerUpdate)) { - Stream watchingPlayers = PlayerStream.watching(world, getPos()); - PacketByteBuf passedData = new PacketByteBuf(Unpooled.buffer()); - passedData.writeBlockPos(pos); - passedData.writeItemStack(inventory.get(0)); - passedData.writeItemStack(inventory.get(1)); - passedData.writeItemStack(inventory.get(2)); - - passedData.writeString(String.valueOf(inventory)); - watchingPlayers.forEach(player -> ServerSidePacketRegistryImpl.INSTANCE.sendToPlayer(player, VisualOverhaul.UPDATE_FURNACE_ITEMS, passedData)); - invUpdate = false; + if (this.world.getBlockState(this.pos).getBlock().is(Blocks.FURNACE)) { + if (!this.world.isClient && (invUpdate || world.getPlayers().size() == playerUpdate)) { + Stream watchingPlayers = PlayerStream.watching(world, getPos()); + PacketByteBuf passedData = new PacketByteBuf(Unpooled.buffer()); + passedData.writeBlockPos(pos); + passedData.writeItemStack(inventory.get(0)); + passedData.writeItemStack(inventory.get(1)); + passedData.writeItemStack(inventory.get(2)); + + passedData.writeString(String.valueOf(inventory)); + watchingPlayers.forEach(player -> ServerSidePacketRegistryImpl.INSTANCE.sendToPlayer(player, VisualOverhaul.UPDATE_FURNACE_ITEMS, passedData)); + invUpdate = false; + } + playerUpdate = world.getPlayers().size(); } - playerUpdate = world.getPlayers().size(); } @Inject(at = @At("RETURN"), method = "getStack", cancellable = true)