Fixed minor tank packet bug

This commit is contained in:
Calclavia 2014-01-19 19:30:00 +08:00
parent bd496c66bd
commit a0bbaee12b
3 changed files with 24 additions and 23 deletions

View file

@ -61,20 +61,6 @@ public abstract class TileFluidNetwork extends TileAdvanced implements IFluidCon
getNetwork().reconstruct(); getNetwork().reconstruct();
} }
@Override
public void onFluidChanged()
{
if (!worldObj.isRemote)
{
if (!FluidUtility.matchExact(prevStack, this.getInternalTank().getFluid()))
{
this.sendTankUpdate();
}
this.prevStack = this.tank.getFluid();
}
}
@Override @Override
public void invalidate() public void invalidate()
{ {
@ -264,10 +250,23 @@ public abstract class TileFluidNetwork extends TileAdvanced implements IFluidCon
public void sendTankUpdate() public void sendTankUpdate()
{ {
System.out.println("Send Amount: " + this.getInternalTank().getFluidAmount());
PacketHandler.sendPacketToClients(ResonantInduction.PACKET_TILE.getPacketWithID(PACKET_TANK, this, getInternalTank().getCapacity(), getInternalTank().writeToNBT(new NBTTagCompound())), this.worldObj, new Vector3(this), 60); PacketHandler.sendPacketToClients(ResonantInduction.PACKET_TILE.getPacketWithID(PACKET_TANK, this, getInternalTank().getCapacity(), getInternalTank().writeToNBT(new NBTTagCompound())), this.worldObj, new Vector3(this), 60);
} }
@Override
public void onFluidChanged()
{
if (!worldObj.isRemote)
{
if (!FluidUtility.matchExact(prevStack, this.getInternalTank().getFluid()))
{
sendTankUpdate();
}
prevStack = tank.getFluid();
}
}
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public AxisAlignedBB getRenderBoundingBox() public AxisAlignedBB getRenderBoundingBox()

View file

@ -67,7 +67,6 @@ public class BlockTank extends BlockFluidNetwork
if (!world.isRemote) if (!world.isRemote)
{ {
return FluidUtility.playerActivatedFluidItem(world, x, y, z, entityplayer, side); return FluidUtility.playerActivatedFluidItem(world, x, y, z, entityplayer, side);
} }
return true; return true;

View file

@ -28,16 +28,19 @@ public class TankNetwork extends FluidNetwork
else if (this.getConnectors().size() > 0) else if (this.getConnectors().size() > 0)
{ {
fillStack = fillStack.copy(); fillStack = fillStack.copy();
for (IFluidConnector part : this.getConnectors())
for (IFluidConnector connector : this.getConnectors())
{ {
part.getInternalTank().setFluid(null); connector.getInternalTank().setFluid(null);
if (part instanceof TileEntity && ((TileEntity) part).yCoord < lowestY) connector.onFluidChanged();
if (connector instanceof TileEntity && ((TileEntity) connector).yCoord < lowestY)
{ {
lowestY = ((TileEntity) part).yCoord; lowestY = ((TileEntity) connector).yCoord;
} }
if (part instanceof TileEntity && ((TileEntity) part).yCoord > highestY) if (connector instanceof TileEntity && ((TileEntity) connector).yCoord > highestY)
{ {
highestY = ((TileEntity) part).yCoord; highestY = ((TileEntity) connector).yCoord;
} }
} }