diff --git a/src/main/java/resonantinduction/mechanical/fluid/network/FluidNetwork.java b/src/main/java/resonantinduction/mechanical/fluid/network/FluidNetwork.java index 61b5a709..ab8805a4 100644 --- a/src/main/java/resonantinduction/mechanical/fluid/network/FluidNetwork.java +++ b/src/main/java/resonantinduction/mechanical/fluid/network/FluidNetwork.java @@ -3,6 +3,9 @@ package resonantinduction.mechanical.fluid.network; import java.util.Set; import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.ForgeSubscribe; +import net.minecraftforge.event.world.WorldEvent.Save; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fluids.FluidTankInfo; @@ -25,6 +28,7 @@ public class FluidNetwork extends Network> connectionMap = new HashMap>(); - public PipeNetwork() - { - NetworkTickHandler.addNetwork(this); - } - @Override public void update() { + System.out.println("PipeNetwork:" + this.toString()); + System.out.println("FluidVol: " + this.getTank().getFluidAmount()); + super.update(); //Slight delay to allow visual effect to take place before draining the pipe's internal tank if (this.ticks % 2 == 0 && this.getTank().getFluidAmount() > 0) @@ -36,23 +33,20 @@ public class PipeNetwork extends FluidNetwork int count = this.connectionMap.size(); for (Entry> entry : this.connectionMap.entrySet()) { - int volPer = stack.amount / count; int sideCount = entry.getValue().size(); for (ForgeDirection dir : entry.getValue()) { - int volPerSide = volPer / sideCount; + int volPer = (stack.amount / count) + (stack.amount % count); + int volPerSide = (volPer / sideCount) + (volPer % count); int maxFill = 1000; TileEntity entity = new Vector3((TileEntity) entry.getKey()).modifyPositionFromSide(dir).getTileEntity(((TileEntity) entry.getKey()).worldObj); if (entity instanceof IFluidPipe) { maxFill = ((IFluidPipe) entity).getMaxFlowRate(); } - int fill = entry.getKey().fill(dir, FluidUtility.getStack(stack, Math.min(volPerSide, maxFill)), true); - volPer -= fill; - stack.amount -= fill; + stack.amount -= entry.getKey().fill(dir, FluidUtility.getStack(stack, Math.min(volPerSide, maxFill)), true); if (sideCount > 1) --sideCount; - if (volPer <= 0) break; } @@ -76,7 +70,7 @@ public class PipeNetwork extends FluidNetwork @Override public boolean continueUpdate() { - return true; + return this.getConnectors().size() > 0; } @Override diff --git a/src/main/java/resonantinduction/mechanical/fluid/prefab/TileFluidNetwork.java b/src/main/java/resonantinduction/mechanical/fluid/prefab/TileFluidNetwork.java index ffac2e0c..823081f3 100644 --- a/src/main/java/resonantinduction/mechanical/fluid/prefab/TileFluidNetwork.java +++ b/src/main/java/resonantinduction/mechanical/fluid/prefab/TileFluidNetwork.java @@ -162,6 +162,7 @@ public class TileFluidNetwork extends TileEntityFluidDevice implements IFluidPar if (previousConnections != renderSides) { this.sendRenderUpdate(); + this.getNetwork().reconstruct(); } } diff --git a/src/main/java/resonantinduction/mechanical/fluid/tank/TankNetwork.java b/src/main/java/resonantinduction/mechanical/fluid/tank/TankNetwork.java index 4f72847e..4d748847 100644 --- a/src/main/java/resonantinduction/mechanical/fluid/tank/TankNetwork.java +++ b/src/main/java/resonantinduction/mechanical/fluid/tank/TankNetwork.java @@ -13,11 +13,7 @@ import universalelectricity.core.net.NetworkTickHandler; * * @author DarkGuardsman */ public class TankNetwork extends FluidNetwork -{ - public TankNetwork() - { - NetworkTickHandler.addNetwork(this); - } +{ @Override public void reloadTanks()