Trying to buffer update rate for tank
Before they could update as fast as they want. Now i'm limiting update to once a second. After this i'm going to work on sending a packet from server tile network to client tile network. Then have the client update its volume. This will reduce packet size but will increase CPU time on the client.
This commit is contained in:
parent
50b1bc8752
commit
6636b47004
1 changed files with 9 additions and 2 deletions
|
@ -40,11 +40,13 @@ import dark.fluid.common.FluidPartsMaterial;
|
|||
public abstract class TileEntityFluidNetworkTile extends TileEntityFluidDevice implements INetworkFluidPart, ISimplePacketReceiver
|
||||
{
|
||||
private int updateTick = 1;
|
||||
public static int refreshRate = 20;
|
||||
protected FluidTank tank;
|
||||
protected FluidTankInfo[] internalTanksInfo = new FluidTankInfo[1];
|
||||
protected List<TileEntity> connectedBlocks = new ArrayList<TileEntity>();
|
||||
public boolean[] renderConnection = new boolean[6];
|
||||
public boolean[] canConnectSide = new boolean[] { true, true, true, true, true, true, true };
|
||||
public boolean updateTank = false;
|
||||
protected int heat = 0, maxHeat = 20000;
|
||||
protected int damage = 0, maxDamage = 1000;
|
||||
protected int subID = 0;
|
||||
|
@ -89,6 +91,11 @@ public abstract class TileEntityFluidNetworkTile extends TileEntityFluidDevice i
|
|||
this.updateTick = this.worldObj.rand.nextInt(5) * 40 + 20;
|
||||
this.refresh();
|
||||
}
|
||||
if (ticks % this.refreshRate == 0)
|
||||
{
|
||||
this.updateTank = false;
|
||||
this.sendTankUpdate(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -248,7 +255,7 @@ public abstract class TileEntityFluidNetworkTile extends TileEntityFluidDevice i
|
|||
//TODO add a catch to this so we don't send a dozen packets for one updates
|
||||
if (update)
|
||||
{
|
||||
this.sendTankUpdate(index);
|
||||
this.updateTank = true;
|
||||
}
|
||||
this.internalTanksInfo[index] = this.getTank().getInfo();
|
||||
}
|
||||
|
@ -268,7 +275,7 @@ public abstract class TileEntityFluidNetworkTile extends TileEntityFluidDevice i
|
|||
{
|
||||
if (update)
|
||||
{
|
||||
this.sendTankUpdate(index);
|
||||
this.updateTank = true;
|
||||
}
|
||||
this.internalTanksInfo[index] = this.getTank().getInfo();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue