Skip to content

Commit

Permalink
Merge branch 'bnorax-dev/1.19.x-fluid_tank_fix' into dev/1.19.x
Browse files Browse the repository at this point in the history
  • Loading branch information
thedarkcolour committed Jul 1, 2024
2 parents 1018209 + d60ff6b commit 8fa0cb7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/main/java/forestry/core/ModuleCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/forestry/core/fluids/TankManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8fa0cb7

Please sign in to comment.