2013-05-23 05:01:19 +00:00
|
|
|
|
|
|
|
package net.minecraftforge.fluids;
|
|
|
|
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
import net.minecraftforge.common.MinecraftForge;
|
|
|
|
import net.minecraftforge.event.Event;
|
|
|
|
|
2013-07-17 04:40:49 +00:00
|
|
|
public class FluidEvent extends Event
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
public final FluidStack fluid;
|
|
|
|
public final int x;
|
|
|
|
public final int y;
|
|
|
|
public final int z;
|
|
|
|
public final World world;
|
|
|
|
|
2013-07-17 04:40:49 +00:00
|
|
|
public FluidEvent(FluidStack fluid, World world, int x, int y, int z)
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
this.fluid = fluid;
|
|
|
|
this.world = world;
|
|
|
|
this.x = x;
|
|
|
|
this.y = y;
|
|
|
|
this.z = z;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Mods should fire this event when they move fluids around.
|
|
|
|
*
|
|
|
|
* @author cpw
|
|
|
|
*
|
|
|
|
*/
|
2013-07-17 04:40:49 +00:00
|
|
|
public static class FluidMotionEvent extends FluidEvent
|
|
|
|
{
|
|
|
|
public FluidMotionEvent(FluidStack fluid, World world, int x, int y, int z)
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
super(fluid, world, x, y, z);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Mods should fire this event when a fluid is {@link IFluidTank#fill(FluidStack, boolean)}
|
|
|
|
* their tank implementation. {@link FluidTank} does.
|
|
|
|
*
|
|
|
|
* @author cpw
|
|
|
|
*
|
|
|
|
*/
|
2013-07-17 04:40:49 +00:00
|
|
|
public static class FluidFillingEvent extends FluidEvent
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
public final IFluidTank tank;
|
2013-07-17 04:40:49 +00:00
|
|
|
public FluidFillingEvent(FluidStack fluid, World world, int x, int y, int z, IFluidTank tank)
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
super(fluid, world, x, y, z);
|
|
|
|
this.tank = tank;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Mods should fire this event when a fluid is {@link IFluidTank#drain(int, boolean)} from their
|
|
|
|
* tank.
|
|
|
|
*
|
|
|
|
* @author cpw
|
|
|
|
*
|
|
|
|
*/
|
2013-07-17 04:40:49 +00:00
|
|
|
public static class FluidDrainingEvent extends FluidEvent
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
public final IFluidTank tank;
|
2013-07-17 04:40:49 +00:00
|
|
|
public FluidDrainingEvent(FluidStack fluid, World world, int x, int y, int z, IFluidTank tank)
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
super(fluid, world, x, y, z);
|
|
|
|
this.tank = tank;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Mods should fire this event when a fluid "spills", for example, if a block containing fluid
|
|
|
|
* is broken.
|
|
|
|
*
|
|
|
|
* @author cpw
|
|
|
|
*
|
|
|
|
*/
|
2013-07-17 04:40:49 +00:00
|
|
|
public static class FluidSpilledEvent extends FluidEvent
|
|
|
|
{
|
|
|
|
public FluidSpilledEvent(FluidStack fluid, World world, int x, int y, int z)
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
super(fluid, world, x, y, z);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A handy shortcut for firing the various fluid events.
|
|
|
|
*
|
|
|
|
* @param event
|
|
|
|
*/
|
2013-07-17 04:40:49 +00:00
|
|
|
public static final void fireEvent(FluidEvent event)
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
MinecraftForge.EVENT_BUS.post(event);
|
|
|
|
}
|
|
|
|
}
|