mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-10-26 14:24:40 +00:00
Fixed free power bug.
This commit is contained in:
1 parent
7679950dae
commit
6d398da114
1 file changed
+10
-9
@@ -193,16 +193,17 @@ public class NetworkPowerManager {
|
||||
float energyLeft = energyStored;
|
||||
float given = 0;
|
||||
for (IPowerConduit con : network.getConduits()) {
|
||||
// NB: use ceil to ensure we dont through away any energy due to rounding
|
||||
// errors
|
||||
float give = (float) Math.ceil(con.getCapacitor().getMaxEnergyStored() * filledRatio);
|
||||
give = Math.min(give, con.getCapacitor().getMaxEnergyStored());
|
||||
give = Math.min(give, energyLeft);
|
||||
con.getPowerHandler().setEnergy(give);
|
||||
given += give;
|
||||
energyLeft -= give;
|
||||
if(energyLeft <= 0) {
|
||||
return;
|
||||
// NB: use ceil to ensure we dont through away any energy due to rounding
|
||||
// errors
|
||||
float give = (float) Math.ceil(con.getCapacitor().getMaxEnergyStored() * filledRatio);
|
||||
give = Math.min(give, con.getCapacitor().getMaxEnergyStored());
|
||||
give = Math.min(give, energyLeft);
|
||||
con.getPowerHandler().setEnergy(give);
|
||||
given += give;
|
||||
energyLeft -= give;
|
||||
} else {
|
||||
con.getPowerHandler().setEnergy(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user