for (StandardTank tank : tanks)
updateGuiData(container, crafters, tank.getTankIndex());
}
public void updateGuiData(Container container, List<EntityPlayerMP> crafters, int tankIndex) {
StandardTank tank = tanks.get(tankIndex);
FluidStack fluidStack = tank.getFluid();
FluidStack prev = prevFluidStacks.get(tankIndex);
int color = tank.getColor();
int pColor = prevColor.get(tankIndex);
for (EntityPlayerMP player : crafters) {
if (fluidStack == null ^ prev == null) {
int fluidId = -1;
int fluidAmount = 0;
if (fluidStack != null) {
fluidId = fluidStack.fluidID;
fluidAmount = fluidStack.amount;
}
player.sendProgressBarUpdate(container, tankIndex * NETWORK_DATA + 0, fluidId);
PacketGuiInteger packet = new PacketGuiInteger(container.windowId, tankIndex * NETWORK_DATA + 1, fluidAmount);
Proxies.net.sendToPlayer(packet, player);
} else if (fluidStack != null && prev != null) {
if (fluidStack.getFluid() != prev.getFluid())
player.sendProgressBarUpdate(container, tankIndex * NETWORK_DATA + 0, fluidStack.fluidID);
if (fluidStack.amount != prev.amount) {
PacketGuiInteger packet = new PacketGuiInteger(container.windowId, tankIndex * NETWORK_DATA + 1, fluidStack.amount);
Proxies.net.sendToPlayer(packet, player);
}
if (color != pColor) {
PacketGuiInteger packet = new PacketGuiInteger(container.windowId, tankIndex * NETWORK_DATA + 2, color);
Proxies.net.sendToPlayer(packet, player);
}
}
}
prevFluidStacks.set(tankIndex, tank.getFluid() == null ? null : tank.getFluid().copy());
prevColor.set(tankIndex, color);
}