Use defined scale to calculate when to send updates, atm 100 possible packet stages

This commit is contained in:
Aidan C. Brady 2013-12-17 14:57:19 -05:00
parent 60e2666a29
commit 4a7b862fb7
2 changed files with 6 additions and 4 deletions

View file

@ -32,7 +32,7 @@ public class GasNetwork extends DynamicNetwork<IGasHandler, GasNetwork>
public float gasScale;
public float prevScale;
/** Sent from server to client, actual stored buffer scale */
/** Sent from server to client, actual stored buffer scale. Used by server as last-update scale. */
public float definedScale;
public Gas refGas = null;
@ -202,7 +202,7 @@ public class GasNetwork extends DynamicNetwork<IGasHandler, GasNetwork>
transferDelay--;
}
if(Math.abs(getScale()-prevScale) > 0.01 || (getScale() != prevScale && (getScale() == 0 || getScale() == 1)))
if(Math.abs(getScale()-definedScale) > 0.01 || (getScale() != prevScale && (getScale() == 0 || getScale() == 1)))
{
needsUpdate = true;
}
@ -213,6 +213,7 @@ public class GasNetwork extends DynamicNetwork<IGasHandler, GasNetwork>
{
MinecraftForge.EVENT_BUS.post(new GasTransferEvent(this, gasStored != null ? gasStored.getGas().getID() : -1, didTransfer, getScale()));
needsUpdate = false;
definedScale = getScale();
}
prevTransfer = didTransfer;

View file

@ -37,7 +37,7 @@ public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork>
public float fluidScale;
public float prevScale;
/** Sent from server to client, actual stored buffer scale */
/** Sent from server to client, actual stored buffer scale. Used by server as last-update scale. */
public float definedScale;
public Fluid refFluid = null;
@ -206,7 +206,7 @@ public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork>
transferDelay--;
}
if(Math.abs(getScale()-prevScale) > 0.01 || (getScale() != prevScale && (getScale() == 0 || getScale() == 1)))
if(Math.abs(getScale()-definedScale) > 0.01 || (getScale() != prevScale && (getScale() == 0 || getScale() == 1)))
{
needsUpdate = true;
}
@ -217,6 +217,7 @@ public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork>
{
MinecraftForge.EVENT_BUS.post(new FluidTransferEvent(this, fluidStored != null ? fluidStored.getFluid().getID() : -1, didTransfer, getScale()));
needsUpdate = false;
definedScale = getScale();
}
prevTransfer = didTransfer;