Separate the current buffer from the throughput when examining a network
This commit is contained in:
parent
d0f64ebc11
commit
ac07e54a1c
5 changed files with 45 additions and 18 deletions
|
@ -39,6 +39,8 @@ public class GasNetwork extends DynamicNetwork<IGasHandler, GasNetwork>
|
|||
public GasStack gasStored;
|
||||
public int prevStored;
|
||||
|
||||
public int prevTransferAmount = 0;
|
||||
|
||||
public GasNetwork(IGridTransmitter<GasNetwork>... varPipes)
|
||||
{
|
||||
transmitters.addAll(Arrays.asList(varPipes));
|
||||
|
@ -209,6 +211,8 @@ public class GasNetwork extends DynamicNetwork<IGasHandler, GasNetwork>
|
|||
|
||||
if(FMLCommonHandler.instance().getEffectiveSide().isServer())
|
||||
{
|
||||
prevTransferAmount = 0;
|
||||
|
||||
if(transferDelay == 0)
|
||||
{
|
||||
didTransfer = false;
|
||||
|
@ -236,7 +240,8 @@ public class GasNetwork extends DynamicNetwork<IGasHandler, GasNetwork>
|
|||
|
||||
if(gasStored != null)
|
||||
{
|
||||
gasStored.amount -= tickEmit(gasStored);
|
||||
prevTransferAmount = tickEmit(gasStored);
|
||||
gasStored.amount -= prevTransferAmount;
|
||||
|
||||
if(gasStored.amount <= 0)
|
||||
{
|
||||
|
@ -461,8 +466,14 @@ public class GasNetwork extends DynamicNetwork<IGasHandler, GasNetwork>
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getFlow()
|
||||
public String getStored()
|
||||
{
|
||||
return gasStored != null ? gasStored.getGas().getLocalizedName() + " (" + gasStored.amount + ")" : "None";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFlow()
|
||||
{
|
||||
return Integer.toString(prevTransferAmount) + "/t";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@ public interface ITransmitterNetwork<A, N extends DynamicNetwork<A, N>>
|
|||
|
||||
public String getNeeded();
|
||||
|
||||
public String getStored();
|
||||
|
||||
public String getFlow();
|
||||
|
||||
public Set<A> getAcceptors(Object... data);
|
||||
|
|
|
@ -34,7 +34,7 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
|
|||
|
||||
private double lastPowerScale = 0;
|
||||
private double joulesTransmitted = 0;
|
||||
private double joulesLastTick = 0;
|
||||
private double jouleBufferLastTick = 0;
|
||||
|
||||
public double clientEnergyScale = 0;
|
||||
|
||||
|
@ -63,10 +63,10 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
|
|||
{
|
||||
if(net != null)
|
||||
{
|
||||
if(net.joulesLastTick > joulesLastTick || net.clientEnergyScale > clientEnergyScale)
|
||||
if(net.jouleBufferLastTick > jouleBufferLastTick || net.clientEnergyScale > clientEnergyScale)
|
||||
{
|
||||
clientEnergyScale = net.clientEnergyScale;
|
||||
joulesLastTick = net.joulesLastTick;
|
||||
jouleBufferLastTick = net.jouleBufferLastTick;
|
||||
joulesTransmitted = net.joulesTransmitted;
|
||||
lastPowerScale = net.lastPowerScale;
|
||||
}
|
||||
|
@ -154,6 +154,7 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
|
|||
}
|
||||
} while(tryAgain);
|
||||
|
||||
joulesTransmitted = sent;
|
||||
return sent;
|
||||
}
|
||||
|
||||
|
@ -224,8 +225,6 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
joulesTransmitted += sent;
|
||||
}
|
||||
|
||||
return sent;
|
||||
|
@ -411,18 +410,18 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
|
|||
|
||||
public double getPowerScale()
|
||||
{
|
||||
return Math.max(joulesLastTick == 0 ? 0 : Math.min(Math.ceil(Math.log10(getPower())*2)/10, 1), getCapacity() == 0 ? 0 : electricityStored/getCapacity());
|
||||
return Math.max(jouleBufferLastTick == 0 ? 0 : Math.min(Math.ceil(Math.log10(getPower())*2)/10, 1), getCapacity() == 0 ? 0 : electricityStored/getCapacity());
|
||||
}
|
||||
|
||||
public void clearJoulesTransmitted()
|
||||
{
|
||||
joulesLastTick = joulesTransmitted;
|
||||
jouleBufferLastTick = electricityStored;
|
||||
joulesTransmitted = 0;
|
||||
}
|
||||
|
||||
public double getPower()
|
||||
{
|
||||
return joulesLastTick * 20;
|
||||
return jouleBufferLastTick * 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -430,7 +429,7 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
|
|||
{
|
||||
EnergyNetwork network = new EnergyNetwork(varTransmitters);
|
||||
network.clientEnergyScale = clientEnergyScale;
|
||||
network.joulesLastTick = joulesLastTick;
|
||||
network.jouleBufferLastTick = jouleBufferLastTick;
|
||||
network.joulesTransmitted = joulesTransmitted;
|
||||
network.lastPowerScale = lastPowerScale;
|
||||
network.electricityStored += electricityStored;
|
||||
|
@ -442,7 +441,7 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
|
|||
{
|
||||
EnergyNetwork network = new EnergyNetwork(collection);
|
||||
network.clientEnergyScale = clientEnergyScale;
|
||||
network.joulesLastTick = joulesLastTick;
|
||||
network.jouleBufferLastTick = jouleBufferLastTick;
|
||||
network.joulesTransmitted = joulesTransmitted;
|
||||
network.lastPowerScale = lastPowerScale;
|
||||
network.electricityStored += electricityStored;
|
||||
|
@ -467,9 +466,15 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
|
|||
return MekanismUtils.getEnergyDisplay(getEnergyNeeded());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStored()
|
||||
{
|
||||
return MekanismUtils.getEnergyDisplay(electricityStored);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFlow()
|
||||
{
|
||||
return MekanismUtils.getPowerDisplay(20*electricityStored);
|
||||
return MekanismUtils.getPowerDisplay(20*joulesTransmitted);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,8 @@ public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork>
|
|||
public FluidStack fluidStored;
|
||||
public int prevStored;
|
||||
|
||||
public int prevTransferAmount = 0;
|
||||
|
||||
public FluidNetwork(IGridTransmitter<FluidNetwork>... varPipes)
|
||||
{
|
||||
transmitters.addAll(Arrays.asList(varPipes));
|
||||
|
@ -456,12 +458,18 @@ public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork>
|
|||
@Override
|
||||
public String getNeeded()
|
||||
{
|
||||
return "Fluid needed (any type): " + (float)getFluidNeeded()/1000F + " buckets";
|
||||
return "Fluid needed: " + (float)getFluidNeeded()/1000F + " buckets";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStored()
|
||||
{
|
||||
return fluidStored == null ? "None" : fluidStored.getFluid().getLocalizedName() + ", " + fluidStored.amount + "mB";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFlow()
|
||||
{
|
||||
return fluidStored == null ? "None" : fluidStored.getFluid().getLocalizedName() + ", " + fluidStored.amount + "mB/tick";
|
||||
return Integer.toString(prevTransferAmount);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,8 +38,9 @@ public class ItemNetworkReader extends ItemEnergized
|
|||
player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + " *Transmitters: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetwork().getSize()));
|
||||
player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + " *Acceptors: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetwork().getAcceptorSize()));
|
||||
player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + " *Needed: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetwork().getNeeded()));
|
||||
player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + " *Power: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetwork().getFlow() ));
|
||||
player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + " *Capacity: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetwork().getCapacity() + "/tick" ));
|
||||
player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + " *Buffer: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetwork().getStored()));
|
||||
player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + " *Throughput: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetwork().getFlow()));
|
||||
player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + " *Capacity: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetwork().getCapacity() + "/tick"));
|
||||
player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------"));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue