Fix negative energy buffer issue

This commit is contained in:
Aidan C. Brady 2014-02-14 17:45:51 -05:00
parent b2e9e03584
commit 27199c9721

View file

@ -67,6 +67,16 @@ public class PartUniversalCable extends PartTransmitter<EnergyNetwork> implement
}
}
else {
if(getTransmitterNetwork(false) != null && getTransmitterNetwork(false).getSize() > 0)
{
double last = lastWrite;
if(last != getSaveShare())
{
MekanismUtils.saveChunk(tile());
}
}
if(cacheEnergy > 0)
{
getTransmitterNetwork().electricityStored += cacheEnergy;
@ -77,6 +87,11 @@ public class PartUniversalCable extends PartTransmitter<EnergyNetwork> implement
super.update();
}
private double getSaveShare()
{
return EnergyNetwork.round(getTransmitterNetwork().electricityStored*(1F/getTransmitterNetwork().transmitters.size()));
}
@Override
public void refreshTransmitterNetwork()
{
@ -105,7 +120,7 @@ public class PartUniversalCable extends PartTransmitter<EnergyNetwork> implement
{
super.save(nbtTags);
double toSave = EnergyNetwork.round(getTransmitterNetwork().electricityStored*(1F/getTransmitterNetwork().transmitters.size()));
double toSave = getSaveShare();
lastWrite = toSave;
nbtTags.setDouble("cacheEnergy", toSave);