Skip to content

Commit

Permalink
Fix ClassCastExeption
Browse files Browse the repository at this point in the history
  • Loading branch information
Motschen committed Jan 23, 2021
1 parent 792e81f commit c2306d7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public void onInitializeClient() {
}
});


ClientSidePacketRegistryImpl.INSTANCE.register(UPDATE_POTION_BOTTLES,
(packetContext, attachedData) -> {
BlockPos pos = attachedData.readBlockPos();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<PlayerEntity> 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<PlayerEntity> 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)
Expand Down

0 comments on commit c2306d7

Please sign in to comment.