From a3e8f0cbe4553a33d6cef99679c72f09b432ae69 Mon Sep 17 00:00:00 2001 From: WaDelma Date: Tue, 20 May 2014 01:39:51 +0300 Subject: [PATCH] Fluid events now know how much fluid is moved Added amount that is being filled/drained to the FluidEvent Added constructors without amount to ensure backwards compability Added deprecation to amountless constructors --- .../net/minecraftforge/fluids/FluidEvent.java | 26 +++++++++++++++++++ .../net/minecraftforge/fluids/FluidTank.java | 6 ++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/minecraftforge/fluids/FluidEvent.java b/src/main/java/net/minecraftforge/fluids/FluidEvent.java index ec8b915140..5229cf2d93 100644 --- a/src/main/java/net/minecraftforge/fluids/FluidEvent.java +++ b/src/main/java/net/minecraftforge/fluids/FluidEvent.java @@ -46,10 +46,23 @@ public class FluidEvent extends Event public static class FluidFillingEvent extends FluidEvent { public final IFluidTank tank; + public final int amount; + + /** + * @deprecated Will be removed in 1.8 + * + */ + @Deprecated public FluidFillingEvent(FluidStack fluid, World world, int x, int y, int z, IFluidTank tank) + { + this(fluid, world, x, y, z, tank, -1); + } + + public FluidFillingEvent(FluidStack fluid, World world, int x, int y, int z, IFluidTank tank, int amount) { super(fluid, world, x, y, z); this.tank = tank; + this.amount = amount; } } @@ -63,9 +76,22 @@ public class FluidEvent extends Event public static class FluidDrainingEvent extends FluidEvent { public final IFluidTank tank; + public final int amount; + + /** + * @deprecated Will be removed in 1.8 + * + */ + @Deprecated public FluidDrainingEvent(FluidStack fluid, World world, int x, int y, int z, IFluidTank tank) + { + this(fluid, world, x, y, z, tank, -1); + } + + public FluidDrainingEvent(FluidStack fluid, World world, int x, int y, int z, IFluidTank tank, int amount) { super(fluid, world, x, y, z); + this.amount = amount; this.tank = tank; } } diff --git a/src/main/java/net/minecraftforge/fluids/FluidTank.java b/src/main/java/net/minecraftforge/fluids/FluidTank.java index c4d3259529..d6e5a5a8d3 100644 --- a/src/main/java/net/minecraftforge/fluids/FluidTank.java +++ b/src/main/java/net/minecraftforge/fluids/FluidTank.java @@ -127,7 +127,7 @@ public class FluidTank implements IFluidTank if (tile != null) { - FluidEvent.fireEvent(new FluidEvent.FluidFillingEvent(fluid, tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord, this)); + FluidEvent.fireEvent(new FluidEvent.FluidFillingEvent(fluid, tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord, this, fluid.amount)); } return fluid.amount; } @@ -150,7 +150,7 @@ public class FluidTank implements IFluidTank if (tile != null) { - FluidEvent.fireEvent(new FluidEvent.FluidFillingEvent(fluid, tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord, this)); + FluidEvent.fireEvent(new FluidEvent.FluidFillingEvent(fluid, tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord, this, filled)); } return filled; } @@ -180,7 +180,7 @@ public class FluidTank implements IFluidTank if (tile != null) { - FluidEvent.fireEvent(new FluidEvent.FluidDrainingEvent(fluid, tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord, this)); + FluidEvent.fireEvent(new FluidEvent.FluidDrainingEvent(fluid, tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord, this, drained)); } } return stack;