diff --git a/src/main/java/resonantinduction/mechanical/fluid/network/FluidNetwork.java b/src/main/java/resonantinduction/mechanical/fluid/network/FluidNetwork.java index b0f18cd85..00028b3cb 100644 --- a/src/main/java/resonantinduction/mechanical/fluid/network/FluidNetwork.java +++ b/src/main/java/resonantinduction/mechanical/fluid/network/FluidNetwork.java @@ -10,8 +10,9 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; -import resonantinduction.api.fluid.IFluidNetwork; import resonantinduction.api.fluid.IFluidConnector; +import resonantinduction.api.fluid.IFluidNetwork; +import resonantinduction.mechanical.fluid.tank.TileTank; import universalelectricity.api.net.IConnector; import universalelectricity.core.net.ConnectionPathfinder; import universalelectricity.core.net.Network; @@ -99,6 +100,7 @@ public abstract class FluidNetwork extends Network 0) + /* + * Slight delay to allow visual effect to take place before draining the pipe's internal + * tank + */ + if (this.getTank().getFluidAmount() > 0) { FluidStack stack = this.getTank().getFluid().copy(); int count = this.connectionMap.size(); + for (Entry> entry : this.connectionMap.entrySet()) { int sideCount = entry.getValue().size(); @@ -46,7 +46,9 @@ public class PipeNetwork extends FluidNetwork { maxFill = ((IFluidPipe) entity).getMaxFlowRate(); } + stack.amount -= entry.getKey().fill(dir, FluidUtility.getStack(stack, Math.min(volPerSide, maxFill)), true); + if (sideCount > 1) --sideCount; if (volPer <= 0) @@ -57,6 +59,7 @@ public class PipeNetwork extends FluidNetwork if (stack == null || stack.amount <= 0) break; } + this.getTank().setFluid(stack); // TODO check for change before rebuilding this.rebuildHandler(); @@ -72,7 +75,7 @@ public class PipeNetwork extends FluidNetwork @Override public boolean continueUpdate() { - return true;// this.getConnectors().size() > 0; + return this.getConnectors().size() > 0; } @Override diff --git a/src/main/java/resonantinduction/mechanical/fluid/prefab/BlockFluidNetwork.java b/src/main/java/resonantinduction/mechanical/fluid/prefab/BlockFluidNetwork.java index 4f61c29ed..a274913b1 100644 --- a/src/main/java/resonantinduction/mechanical/fluid/prefab/BlockFluidNetwork.java +++ b/src/main/java/resonantinduction/mechanical/fluid/prefab/BlockFluidNetwork.java @@ -15,6 +15,18 @@ public class BlockFluidNetwork extends BlockRI super(name); } + @Override + public void onBlockAdded(World world, int x, int y, int z) + { + TileEntity tile = world.getBlockTileEntity(x, y, z); + + if (tile instanceof TileFluidNetwork) + { + ((TileFluidNetwork) tile).refresh(); + ((TileFluidNetwork) tile).getNetwork().reconstruct(); + } + } + @Override public void onNeighborBlockChange(World world, int x, int y, int z, int par5) { diff --git a/src/main/java/resonantinduction/mechanical/fluid/prefab/TileFluidNetwork.java b/src/main/java/resonantinduction/mechanical/fluid/prefab/TileFluidNetwork.java index 7b370327d..e18d731e5 100644 --- a/src/main/java/resonantinduction/mechanical/fluid/prefab/TileFluidNetwork.java +++ b/src/main/java/resonantinduction/mechanical/fluid/prefab/TileFluidNetwork.java @@ -100,31 +100,19 @@ public abstract class TileFluidNetwork extends TileEntit @Override public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { - if (this.getNetwork() != null && resource != null) - { - return this.getNetwork().fill(this, from, resource, doFill); - } - return 0; + return this.getNetwork().fill(this, from, resource, doFill); } @Override public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { - if (this.getNetwork() != null && resource != null) - { - return this.getNetwork().drain(this, from, resource, doDrain); - } - return null; + return this.getNetwork().drain(this, from, resource, doDrain); } @Override public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { - if (this.getNetwork() != null) - { - return this.getNetwork().drain(this, from, maxDrain, doDrain); - } - return null; + return this.getNetwork().drain(this, from, maxDrain, doDrain); } @Override