2013-05-23 01:01:19 -04:00
|
|
|
|
|
|
|
|
package net.minecraftforge.fluids;
|
|
|
|
|
|
2016-03-01 04:58:03 -08:00
|
|
|
import net.minecraft.util.math.BlockPos;
|
2013-05-23 01:01:19 -04:00
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
import net.minecraftforge.common.MinecraftForge;
|
2014-11-25 19:56:35 -08:00
|
|
|
import net.minecraftforge.fml.common.eventhandler.Event;
|
2013-05-23 01:01:19 -04:00
|
|
|
|
2013-07-16 21:40:49 -07:00
|
|
|
public class FluidEvent extends Event
|
|
|
|
|
{
|
2016-03-24 13:14:39 +03:00
|
|
|
private final FluidStack fluid;
|
|
|
|
|
private final World world;
|
|
|
|
|
private final BlockPos pos;
|
2013-05-23 01:01:19 -04:00
|
|
|
|
2014-11-25 19:56:35 -08:00
|
|
|
public FluidEvent(FluidStack fluid, World world, BlockPos pos)
|
2013-07-16 21:40:49 -07:00
|
|
|
{
|
2013-05-23 01:01:19 -04:00
|
|
|
this.fluid = fluid;
|
|
|
|
|
this.world = world;
|
2014-11-25 19:56:35 -08:00
|
|
|
this.pos = pos;
|
2013-05-23 01:01:19 -04:00
|
|
|
}
|
|
|
|
|
|
2016-03-24 13:14:39 +03:00
|
|
|
public FluidStack getFluid()
|
|
|
|
|
{
|
|
|
|
|
return fluid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public World getWorld()
|
|
|
|
|
{
|
|
|
|
|
return world;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public BlockPos getPos()
|
|
|
|
|
{
|
|
|
|
|
return pos;
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-23 01:01:19 -04:00
|
|
|
/**
|
|
|
|
|
* Mods should fire this event when they move fluids around.
|
2014-11-25 19:56:35 -08:00
|
|
|
*
|
2013-05-23 01:01:19 -04:00
|
|
|
*/
|
2013-07-16 21:40:49 -07:00
|
|
|
public static class FluidMotionEvent extends FluidEvent
|
|
|
|
|
{
|
2014-11-25 19:56:35 -08:00
|
|
|
public FluidMotionEvent(FluidStack fluid, World world, BlockPos pos)
|
2013-07-16 21:40:49 -07:00
|
|
|
{
|
2014-11-25 19:56:35 -08:00
|
|
|
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.
|
2014-11-25 19:56:35 -08:00
|
|
|
*
|
2013-05-23 01:01:19 -04:00
|
|
|
*/
|
2013-07-16 21:40:49 -07:00
|
|
|
public static class FluidFillingEvent extends FluidEvent
|
|
|
|
|
{
|
2016-03-24 13:14:39 +03:00
|
|
|
private final IFluidTank tank;
|
|
|
|
|
private final int amount;
|
2014-05-20 01:39:51 +03:00
|
|
|
|
2014-11-25 19:56:35 -08:00
|
|
|
public FluidFillingEvent(FluidStack fluid, World world, BlockPos pos, IFluidTank tank, int amount)
|
2014-05-20 01:39:51 +03:00
|
|
|
{
|
2014-11-25 19:56:35 -08:00
|
|
|
super(fluid, world, pos);
|
2013-05-23 01:01:19 -04:00
|
|
|
this.tank = tank;
|
2014-05-20 01:39:51 +03:00
|
|
|
this.amount = amount;
|
2013-05-23 01:01:19 -04:00
|
|
|
}
|
2016-03-24 13:14:39 +03:00
|
|
|
|
|
|
|
|
public IFluidTank getTank()
|
|
|
|
|
{
|
|
|
|
|
return tank;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getAmount()
|
|
|
|
|
{
|
|
|
|
|
return 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.
|
2014-11-25 19:56:35 -08:00
|
|
|
*
|
2013-05-23 01:01:19 -04:00
|
|
|
*/
|
2013-07-16 21:40:49 -07:00
|
|
|
public static class FluidDrainingEvent extends FluidEvent
|
|
|
|
|
{
|
2016-03-24 13:14:39 +03:00
|
|
|
private final IFluidTank tank;
|
|
|
|
|
private final int amount;
|
2014-05-20 01:39:51 +03:00
|
|
|
|
2014-11-25 19:56:35 -08:00
|
|
|
public FluidDrainingEvent(FluidStack fluid, World world, BlockPos pos, IFluidTank tank, int amount)
|
2013-07-16 21:40:49 -07:00
|
|
|
{
|
2014-11-25 19:56:35 -08:00
|
|
|
super(fluid, world, pos);
|
2014-05-20 01:39:51 +03:00
|
|
|
this.amount = amount;
|
2013-05-23 01:01:19 -04:00
|
|
|
this.tank = tank;
|
|
|
|
|
}
|
2016-03-24 13:14:39 +03:00
|
|
|
|
|
|
|
|
public IFluidTank getTank()
|
|
|
|
|
{
|
|
|
|
|
return tank;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getAmount()
|
|
|
|
|
{
|
|
|
|
|
return amount;
|
|
|
|
|
}
|
2013-05-23 01:01:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Mods should fire this event when a fluid "spills", for example, if a block containing fluid
|
|
|
|
|
* is broken.
|
2014-11-25 19:56:35 -08:00
|
|
|
*
|
2013-05-23 01:01:19 -04:00
|
|
|
*/
|
2013-07-16 21:40:49 -07:00
|
|
|
public static class FluidSpilledEvent extends FluidEvent
|
|
|
|
|
{
|
2014-11-25 19:56:35 -08:00
|
|
|
public FluidSpilledEvent(FluidStack fluid, World world, BlockPos pos)
|
2013-07-16 21:40:49 -07:00
|
|
|
{
|
2014-11-25 19:56:35 -08:00
|
|
|
super(fluid, world, pos);
|
2013-05-23 01:01:19 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A handy shortcut for firing the various fluid events.
|
2014-11-25 19:56:35 -08:00
|
|
|
*
|
2013-05-23 01:01:19 -04:00
|
|
|
* @param event
|
|
|
|
|
*/
|
2013-07-16 21:40:49 -07:00
|
|
|
public static final void fireEvent(FluidEvent event)
|
|
|
|
|
{
|
2013-05-23 01:01:19 -04:00
|
|
|
MinecraftForge.EVENT_BUS.post(event);
|
|
|
|
|
}
|
|
|
|
|
}
|