EnergyNetwork distribution merge/split complete, will do fluid and gas stuff tomorrow

This commit is contained in:
Aidan Brady 2013-12-16 19:08:52 -05:00
parent 7730649ab3
commit b78b1dc850
2 changed files with 4 additions and 24 deletions

View file

@ -56,7 +56,7 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
public static double round(double d) public static double round(double d)
{ {
return Math.round(d * 100)/100; return Math.round(d * 10000)/10000;
} }
public EnergyNetwork(Set<EnergyNetwork> networks) public EnergyNetwork(Set<EnergyNetwork> networks)
@ -73,7 +73,6 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
lastPowerScale = net.lastPowerScale; lastPowerScale = net.lastPowerScale;
} }
System.out.println("ADDING " + net.electricityStored);
electricityStored += net.electricityStored; electricityStored += net.electricityStored;
addAllTransmitters(net.transmitters); addAllTransmitters(net.transmitters);
@ -105,7 +104,6 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
{ {
if(FMLCommonHandler.instance().getEffectiveSide().isServer()) if(FMLCommonHandler.instance().getEffectiveSide().isServer())
{ {
System.out.println("--start--");
double[] caps = new double[networks.size()]; double[] caps = new double[networks.size()];
double cap = 0; double cap = 0;
@ -115,19 +113,14 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
cap += network.getCapacity(); cap += network.getCapacity();
} }
System.out.println("capping at: " + cap);
electricityStored = Math.min(cap, electricityStored); electricityStored = Math.min(cap, electricityStored);
double[] percent = ListUtils.percent(caps); double[] percent = ListUtils.percent(caps);
for(EnergyNetwork network : networks) for(EnergyNetwork network : networks)
{ {
System.out.println(electricityStored + " " + percent[networks.indexOf(network)]); network.electricityStored = round(percent[networks.indexOf(network)]*electricityStored);
System.out.println("Setting to " + percent[networks.indexOf(network)]*electricityStored);
network.electricityStored = percent[networks.indexOf(network)]*electricityStored;
} }
System.out.println("--end--");
} }
} }
@ -441,13 +434,7 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
if(electricityStored > 0) if(electricityStored > 0)
{ {
double emitted = electricityStored - tickEmit(electricityStored); electricityStored -= (electricityStored - tickEmit(electricityStored));
electricityStored -= emitted;
if(emitted > 0)
{
System.out.println(emitted);
}
} }
} }
} }
@ -477,7 +464,6 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
network.joulesTransmitted = joulesTransmitted; network.joulesTransmitted = joulesTransmitted;
network.lastPowerScale = lastPowerScale; network.lastPowerScale = lastPowerScale;
network.electricityStored += electricityStored; network.electricityStored += electricityStored;
System.out.println("VAR ADDING " + electricityStored);
return network; return network;
} }
@ -490,7 +476,6 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
network.joulesTransmitted = joulesTransmitted; network.joulesTransmitted = joulesTransmitted;
network.lastPowerScale = lastPowerScale; network.lastPowerScale = lastPowerScale;
network.electricityStored += electricityStored; network.electricityStored += electricityStored;
System.out.println("COLLECTION Adding " + electricityStored);
return network; return network;
} }

View file

@ -52,7 +52,6 @@ public class PartUniversalCable extends PartTransmitter<EnergyNetwork> implement
else { else {
if(cacheEnergy > 0) if(cacheEnergy > 0)
{ {
System.out.println("More cache " + cacheEnergy);
getTransmitterNetwork().electricityStored += cacheEnergy; getTransmitterNetwork().electricityStored += cacheEnergy;
cacheEnergy = 0; cacheEnergy = 0;
} }
@ -74,10 +73,7 @@ public class PartUniversalCable extends PartTransmitter<EnergyNetwork> implement
{ {
super.save(nbtTags); super.save(nbtTags);
double remains = getTransmitterNetwork().electricityStored%getTransmitterNetwork().getMeanCapacity(); double toSave = EnergyNetwork.round(getTransmitterNetwork().electricityStored*(1F/getTransmitterNetwork().transmitters.size()));
double toSave = (getTransmitterNetwork().electricityStored-remains)/getTransmitterNetwork().getMeanCapacity();
toSave = EnergyNetwork.round(toSave + remains);
System.out.println("SAVING " + toSave);
lastWrite = toSave; lastWrite = toSave;
nbtTags.setDouble("cacheEnergy", toSave); nbtTags.setDouble("cacheEnergy", toSave);
@ -99,7 +95,6 @@ public class PartUniversalCable extends PartTransmitter<EnergyNetwork> implement
@Override @Override
public void preSingleMerge(EnergyNetwork network) public void preSingleMerge(EnergyNetwork network)
{ {
System.out.println("Cache " + cacheEnergy);
network.electricityStored += cacheEnergy; network.electricityStored += cacheEnergy;
cacheEnergy = 0; cacheEnergy = 0;
} }