diff --git a/src/main/java/resonantinduction/battery/BatteryStructure.java b/src/main/java/resonantinduction/battery/BatteryStructure.java index 2c78158bd..e0ea8c625 100644 --- a/src/main/java/resonantinduction/battery/BatteryStructure.java +++ b/src/main/java/resonantinduction/battery/BatteryStructure.java @@ -1,13 +1,12 @@ package resonantinduction.battery; -import java.util.Iterator; +import java.util.Arrays; -import universalelectricity.api.net.IConnector; import calclavia.lib.multiblock.structure.Structure; public class BatteryStructure extends Structure { - public void redistribute() + public void redistribute(TileBattery... exclusion) { long totalEnergy = 0; @@ -15,21 +14,29 @@ public class BatteryStructure extends Structure { totalEnergy += battery.getEnergy(null); } + + int amountOfNodes = this.get().size() - exclusion.length; - long totalPerBattery = totalEnergy / this.get().size(); - long totalPerBatteryRemainder = totalPerBattery + totalEnergy % this.get().size(); - - TileBattery firstNode = this.getFirstNode(); - - for (TileBattery battery : this.get()) + if (totalEnergy > 0 && amountOfNodes > 0) { - if (battery == firstNode) + long totalPerBattery = totalEnergy / amountOfNodes; + long totalPerBatteryRemainder = totalPerBattery + totalEnergy % amountOfNodes; + + TileBattery firstNode = this.getFirstNode(); + + for (TileBattery battery : this.get()) { - battery.setEnergy(null, totalPerBatteryRemainder); - } - else - { - battery.setEnergy(null, totalPerBattery); + if (!Arrays.asList(exclusion).contains(battery)) + { + if (battery == firstNode) + { + battery.setEnergy(null, totalPerBatteryRemainder); + } + else + { + battery.setEnergy(null, totalPerBattery); + } + } } } } diff --git a/src/main/java/resonantinduction/battery/BlockBattery.java b/src/main/java/resonantinduction/battery/BlockBattery.java index 1a04d2df6..67319e989 100644 --- a/src/main/java/resonantinduction/battery/BlockBattery.java +++ b/src/main/java/resonantinduction/battery/BlockBattery.java @@ -32,10 +32,6 @@ public class BlockBattery extends BlockBase implements ITileEntityProvider @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) { - if (!world.isRemote) - { - System.out.println(((TileBattery) world.getBlockTileEntity(x, y, z)).getNetwork().hashCode()); - } return true; } diff --git a/src/main/java/resonantinduction/battery/TileBattery.java b/src/main/java/resonantinduction/battery/TileBattery.java index dfe96df46..478507ffe 100644 --- a/src/main/java/resonantinduction/battery/TileBattery.java +++ b/src/main/java/resonantinduction/battery/TileBattery.java @@ -75,7 +75,7 @@ public class TileBattery extends TileElectrical implements IConnector