From c47173f4e68f422bf2ae1f4d3128bf0fa6895938 Mon Sep 17 00:00:00 2001 From: asiekierka Date: Tue, 16 Dec 2014 09:42:08 +0100 Subject: [PATCH] add PipeEventFluid support - FindDest --- .../transport/PipeTransportFluids.java | 27 ++++++++++++------- .../pipes/events/PipeEventFluid.java | 11 -------- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/common/buildcraft/transport/PipeTransportFluids.java b/common/buildcraft/transport/PipeTransportFluids.java index 7fed9fb3..ff01c882 100644 --- a/common/buildcraft/transport/PipeTransportFluids.java +++ b/common/buildcraft/transport/PipeTransportFluids.java @@ -8,6 +8,7 @@ */ package buildcraft.transport; +import java.util.ArrayList; import java.util.BitSet; import java.util.HashMap; import java.util.Map; @@ -38,6 +39,7 @@ import buildcraft.transport.pipes.PipeFluidsSandstone; import buildcraft.transport.pipes.PipeFluidsStone; import buildcraft.transport.pipes.PipeFluidsVoid; import buildcraft.transport.pipes.PipeFluidsWood; +import buildcraft.transport.pipes.events.PipeEventFluid; public class PipeTransportFluids extends PipeTransport implements IFluidHandler { public static final Map>, Integer> fluidCapacities = new HashMap>, Integer>(); @@ -406,21 +408,26 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler FluidStack testStack = pushStack.copy(); testStack.amount = flowRate; // Move liquid from the center to the output sides + ArrayList realDirections = new ArrayList(); for (ForgeDirection direction : directions) { if (transferState[direction.ordinal()] == TransferState.Output) { - int available = internalTanks[direction.ordinal()].fill(testStack, false); - int ammountToPush = (int) (available / (double) flowRate / outputCount * Math.min(flowRate, totalAvailable)); - if (ammountToPush < 1) { - ammountToPush++; - } + realDirections.add(direction); + } + } + container.pipe.eventBus.handleEvent(new PipeEventFluid.FindDest(pushStack, realDirections)); + for (ForgeDirection direction : realDirections) { + int available = internalTanks[direction.ordinal()].fill(testStack, false); + int ammountToPush = (int) (available / (double) flowRate / outputCount * Math.min(flowRate, totalAvailable)); + if (ammountToPush < 1) { + ammountToPush++; + } - FluidStack liquidToPush = internalTanks[ForgeDirection.UNKNOWN.ordinal()].drain(ammountToPush, false); - if (liquidToPush != null) { - int filled = internalTanks[direction.ordinal()].fill(liquidToPush, true); - internalTanks[ForgeDirection.UNKNOWN.ordinal()].drain(filled, true); + FluidStack liquidToPush = internalTanks[ForgeDirection.UNKNOWN.ordinal()].drain(ammountToPush, false); + if (liquidToPush != null) { + int filled = internalTanks[direction.ordinal()].fill(liquidToPush, true); + internalTanks[ForgeDirection.UNKNOWN.ordinal()].drain(filled, true); // if (filled > 0) // FluidEvent.fireEvent(new FluidMotionEvent(liquidToPush, container.getWorldObj(), container.xCoord, container.yCoord, container.zCoord)); - } } } } diff --git a/common/buildcraft/transport/pipes/events/PipeEventFluid.java b/common/buildcraft/transport/pipes/events/PipeEventFluid.java index 848a8bf0..f245dc10 100644 --- a/common/buildcraft/transport/pipes/events/PipeEventFluid.java +++ b/common/buildcraft/transport/pipes/events/PipeEventFluid.java @@ -20,15 +20,4 @@ public abstract class PipeEventFluid extends PipeEvent { this.destinations = destinations; } } - - public static class Fill extends PipeEventFluid { - public final ForgeDirection from; - public final boolean doAdd; - - public Fill(ForgeDirection from, FluidStack fluidStack, boolean doAdd) { - super(fluidStack); - this.from = from; - this.doAdd = doAdd; - } - } }