From 6636b47004455e99ac14695b6b11e886708d7d74 Mon Sep 17 00:00:00 2001 From: DarkGuardsman Date: Sat, 2 Nov 2013 21:03:57 -0400 Subject: [PATCH] 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. --- .../common/prefab/TileEntityFluidNetworkTile.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/dark/fluid/common/prefab/TileEntityFluidNetworkTile.java b/src/dark/fluid/common/prefab/TileEntityFluidNetworkTile.java index 05527520..3da6dfec 100644 --- a/src/dark/fluid/common/prefab/TileEntityFluidNetworkTile.java +++ b/src/dark/fluid/common/prefab/TileEntityFluidNetworkTile.java @@ -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 connectedBlocks = new ArrayList(); 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(); }