diff --git a/src/main/java/forestry/core/ModuleCore.java b/src/main/java/forestry/core/ModuleCore.java index 471573e3e..2765fd487 100644 --- a/src/main/java/forestry/core/ModuleCore.java +++ b/src/main/java/forestry/core/ModuleCore.java @@ -151,6 +151,7 @@ public void registerPackets(IPacketRegistry registry) { registry.serverbound(PacketIdServer.SELECT_CLIMATE_TARGETED, PacketSelectClimateTargeted.class, PacketSelectClimateTargeted::decode, PacketSelectClimateTargeted::handle); registry.serverbound(PacketIdServer.CLIMATE_LISTENER_UPDATE_REQUEST, PacketClimateListenerUpdateRequest.class, PacketClimateListenerUpdateRequest::decode, PacketClimateListenerUpdateRequest::handle); + registry.clientbound(PacketIdClient.TANK_LEVEL_UPDATE, PacketTankLevelUpdate.class, PacketTankLevelUpdate::decode, PacketTankLevelUpdate::handle); registry.clientbound(PacketIdClient.GUI_UPDATE, PacketErrorUpdate.class, PacketErrorUpdate::decode, PacketErrorUpdate::handle); registry.clientbound(PacketIdClient.GUI_LAYOUT_SELECT, PacketGuiStream.class, PacketGuiStream::decode, PacketGuiStream::handle); registry.clientbound(PacketIdClient.GUI_ENERGY, PacketGuiLayoutSelect.class, PacketGuiLayoutSelect::decode, PacketGuiLayoutSelect::handle); @@ -159,7 +160,6 @@ public void registerPackets(IPacketRegistry registry) { registry.clientbound(PacketIdClient.TILE_FORESTRY_ACTIVE, PacketTileStream.class, PacketTileStream::decode, PacketTileStream::handle); registry.clientbound(PacketIdClient.ITEMSTACK_DISPLAY, PacketActiveUpdate.class, PacketActiveUpdate::decode, PacketActiveUpdate::handle); registry.clientbound(PacketIdClient.FX_SIGNAL, PacketItemStackDisplay.class, PacketItemStackDisplay::decode, PacketItemStackDisplay::handle); - registry.clientbound(PacketIdClient.GENOME_TRACKER_UPDATE, PacketTankLevelUpdate.class, PacketTankLevelUpdate::decode, PacketTankLevelUpdate::handle); registry.clientbound(PacketIdClient.UPDATE_CLIMATE, PacketGenomeTrackerSync.class, PacketGenomeTrackerSync::decode, PacketGenomeTrackerSync::handle); registry.clientbound(PacketIdClient.CLIMATE_LISTENER_UPDATE, PacketClimateUpdate.class, PacketClimateUpdate::decode, PacketClimateUpdate::handle); registry.clientbound(PacketIdClient.CLIMATE_PLAYER, PacketClimateListenerUpdate.class, PacketClimateListenerUpdate::decode, PacketClimateListenerUpdate::handle); diff --git a/src/main/java/forestry/core/fluids/TankManager.java b/src/main/java/forestry/core/fluids/TankManager.java index 953a6cb65..90a79b00b 100644 --- a/src/main/java/forestry/core/fluids/TankManager.java +++ b/src/main/java/forestry/core/fluids/TankManager.java @@ -28,6 +28,7 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.ContainerListener; +import net.minecraft.world.level.Level; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidTank; @@ -105,7 +106,7 @@ public void read(CompoundTag data) { if (slot >= 0 && slot < tanks.size()) { StandardTank tank = tanks.get(slot); tank.readFromNBT(compound); - updateTankLevels(tank, false); + updateTankLevels(tank); } } } @@ -261,19 +262,18 @@ public int fill(int tankIndex, FluidStack resource, FluidAction action) { @Override public void updateTankLevels(StandardTank tank) { - updateTankLevels(tank, true); - } - - private void updateTankLevels(StandardTank tank, boolean sendUpdate) { if (!(tile instanceof IRenderableTile)) { return; } + + Level world = tile.getWorldObj(); + if (world == null || world.isClientSide) + return; + int tankIndex = tank.getTankIndex(); - if (sendUpdate) { - PacketTankLevelUpdate tankLevelUpdate = new PacketTankLevelUpdate(tile, tankIndex, tank.getFluid()); - NetworkUtil.sendNetworkPacket(tankLevelUpdate, tile.getCoordinates(), tile.getWorldObj()); - } + PacketTankLevelUpdate tankLevelUpdate = new PacketTankLevelUpdate(tile, tankIndex, tank.getFluid()); + NetworkUtil.sendNetworkPacket(tankLevelUpdate, tile.getCoordinates(), world); } @Override