Fixed a large issue with mass packet updates

What was going on and i didn't see this till now is the tanks were
updating every single time the network's tank changed. Too fix this i've
changed the tanks to no update until after the network recalculates the
tanks volume. This way the tanks will only update if there volume has
changed which was the original design.
This commit is contained in:
DarkGuardsman 2013-11-02 08:49:32 -04:00
parent 1cb08ac305
commit 4a693fee48
4 changed files with 17 additions and 11 deletions

View file

@ -21,11 +21,11 @@ public interface INetworkFluidPart extends IFluidHandler, INetworkPart
/** Fills the pipe in the same way that fill method is called in IFluidHandler. This is used so
* the network has a direct method to access the pipes internal fluid storage */
public int fillTankContent(int index, FluidStack stack, boolean doFill);
public int fillTankContent(int index, FluidStack stack, boolean doFill, boolean update);
/** Removes from from the pipe in the same way that drain method is called in IFluidHandler. This
* is used so the network has a direct method to access the pipes internal fluid storage */
public FluidStack drainTankContent(int index, int volume, boolean doDrain);
public FluidStack drainTankContent(int index, int volume, boolean doDrain, boolean update);
/** Can the fluid pass from one side to the next. Used by path finder to see if the fluid can
* move threw the pipes.

View file

@ -51,7 +51,7 @@ public class NetworkFluidContainers extends NetworkFluidTiles
{
if (part instanceof IFluidHandler)
{
((INetworkFluidPart) part).drainTankContent(0, Integer.MAX_VALUE, true);
((INetworkFluidPart) part).drainTankContent(0, Integer.MAX_VALUE, true, false);
}
if (part instanceof TileEntity && ((TileEntity) part).yCoord < lowestY)
{
@ -85,8 +85,8 @@ public class NetworkFluidContainers extends NetworkFluidTiles
/* Fill all tanks on this level */
for (INetworkFluidPart part : parts)
{
part.drainTankContent(0, Integer.MAX_VALUE, true);
fillStack.amount -= part.fillTankContent(0, FluidHelper.getStack(fillStack, fillvolume), true);
part.drainTankContent(0, Integer.MAX_VALUE, true, false);
fillStack.amount -= part.fillTankContent(0, FluidHelper.getStack(fillStack, fillvolume), true, true);
}
}

View file

@ -132,11 +132,11 @@ public class NetworkFluidTiles extends NetworkTileEntities
if (par instanceof INetworkFluidPart)
{
//EMPTY TANK
((INetworkFluidPart) par).drainTankContent(0, Integer.MAX_VALUE, true);
((INetworkFluidPart) par).drainTankContent(0, Integer.MAX_VALUE, true, false);
//FILL TANK
if (stack != null)
{
stack.amount -= ((INetworkFluidPart) par).fillTankContent(0, FluidHelper.getStack(stack, fillVol), true);
stack.amount -= ((INetworkFluidPart) par).fillTankContent(0, FluidHelper.getStack(stack, fillVol), true, true);
membersFilled++;
}
}

View file

@ -237,7 +237,7 @@ public abstract class TileEntityFluidNetworkTile extends TileEntityFluidDevice i
}
@Override
public int fillTankContent(int index, FluidStack stack, boolean doFill)
public int fillTankContent(int index, FluidStack stack, boolean doFill, boolean update)
{
if (index == 0)
{
@ -246,7 +246,10 @@ public abstract class TileEntityFluidNetworkTile extends TileEntityFluidDevice i
if (p != fill)
{
//TODO add a catch to this so we don't send a dozen packets for one updates
this.sendTankUpdate(index);
if (update)
{
this.sendTankUpdate(index);
}
this.internalTanksInfo[index] = this.getTank().getInfo();
}
return fill;
@ -255,7 +258,7 @@ public abstract class TileEntityFluidNetworkTile extends TileEntityFluidDevice i
}
@Override
public FluidStack drainTankContent(int index, int volume, boolean doDrain)
public FluidStack drainTankContent(int index, int volume, boolean doDrain, boolean update)
{
if (index == 0)
{
@ -263,7 +266,10 @@ public abstract class TileEntityFluidNetworkTile extends TileEntityFluidDevice i
FluidStack stack = this.getTank().drain(volume, doDrain);
if (prev != null && (stack == null || prev.amount != stack.amount))
{
this.sendTankUpdate(index);
if (update)
{
this.sendTankUpdate(index);
}
this.internalTanksInfo[index] = this.getTank().getInfo();
}
return stack;