Files
MinecraftForge/src/main/java/net/minecraftforge/fluids/FluidEvent.java
T

92 lines
2.4 KiB
Java
Raw Normal View History

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