Fix negative energy buffer issue
This commit is contained in:
parent
b2e9e03584
commit
27199c9721
1 changed files with 16 additions and 1 deletions
|
@ -67,6 +67,16 @@ public class PartUniversalCable extends PartTransmitter<EnergyNetwork> implement
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if(getTransmitterNetwork(false) != null && getTransmitterNetwork(false).getSize() > 0)
|
||||||
|
{
|
||||||
|
double last = lastWrite;
|
||||||
|
|
||||||
|
if(last != getSaveShare())
|
||||||
|
{
|
||||||
|
MekanismUtils.saveChunk(tile());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(cacheEnergy > 0)
|
if(cacheEnergy > 0)
|
||||||
{
|
{
|
||||||
getTransmitterNetwork().electricityStored += cacheEnergy;
|
getTransmitterNetwork().electricityStored += cacheEnergy;
|
||||||
|
@ -77,6 +87,11 @@ public class PartUniversalCable extends PartTransmitter<EnergyNetwork> implement
|
||||||
super.update();
|
super.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private double getSaveShare()
|
||||||
|
{
|
||||||
|
return EnergyNetwork.round(getTransmitterNetwork().electricityStored*(1F/getTransmitterNetwork().transmitters.size()));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void refreshTransmitterNetwork()
|
public void refreshTransmitterNetwork()
|
||||||
{
|
{
|
||||||
|
@ -105,7 +120,7 @@ public class PartUniversalCable extends PartTransmitter<EnergyNetwork> implement
|
||||||
{
|
{
|
||||||
super.save(nbtTags);
|
super.save(nbtTags);
|
||||||
|
|
||||||
double toSave = EnergyNetwork.round(getTransmitterNetwork().electricityStored*(1F/getTransmitterNetwork().transmitters.size()));
|
double toSave = getSaveShare();
|
||||||
|
|
||||||
lastWrite = toSave;
|
lastWrite = toSave;
|
||||||
nbtTags.setDouble("cacheEnergy", toSave);
|
nbtTags.setDouble("cacheEnergy", toSave);
|
||||||
|
|
Loading…
Reference in a new issue