001 package net.minecraftforge.liquids; 002 003 import net.minecraft.src.TileEntity; 004 import net.minecraft.src.World; 005 import net.minecraftforge.common.MinecraftForge; 006 import net.minecraftforge.event.Event; 007 008 public class LiquidEvent extends Event { 009 public final LiquidStack liquid; 010 public final int x; 011 public final int y; 012 public final int z; 013 public final World world; 014 015 public LiquidEvent(LiquidStack liquid, World world, int x, int y, int z) 016 { 017 this.liquid = liquid; 018 this.world = world; 019 this.x = x; 020 this.y = y; 021 this.z = z; 022 } 023 024 /** 025 * Mods should fire this event when they move liquids around (pipe networks etc) 026 * 027 * @author cpw 028 * 029 */ 030 public static class LiquidMotionEvent extends LiquidEvent { 031 public LiquidMotionEvent(LiquidStack liquid, World world, int x, int y, int z) { 032 super(liquid, world, x, y, z); 033 } 034 } 035 036 /** 037 * Mods should fire this event when a liquid is {@link ILiquidTank#fill(LiquidStack, boolean)} their tank implementation. 038 * {@link LiquidTank} does. 039 * 040 * @author cpw 041 * 042 */ 043 public static class LiquidFillingEvent extends LiquidEvent { 044 public final ILiquidTank tank; 045 046 public LiquidFillingEvent(LiquidStack liquid, World world, int x, int y, int z, ILiquidTank tank) { 047 super(liquid, world, x, y, z); 048 this.tank = tank; 049 } 050 } 051 052 /** 053 * Mods should fire this event when a liquid is {@link ILiquidTank#drain(int, boolean)} from their tank. 054 * @author cpw 055 * 056 */ 057 public static class LiquidDrainingEvent extends LiquidEvent { 058 public final ILiquidTank tank; 059 060 public LiquidDrainingEvent(LiquidStack liquid, World world, int x, int y, int z, ILiquidTank tank) { 061 super(liquid, world, x, y, z); 062 this.tank = tank; 063 } 064 } 065 066 067 /** 068 * Mods should fire this event when a liquid "spills", for example, if a block containing liquid is broken. 069 * 070 * @author cpw 071 * 072 */ 073 public static class LiquidSpilledEvent extends LiquidEvent { 074 public LiquidSpilledEvent(LiquidStack liquid, World world, int x, int y, int z) { 075 super(liquid, world, x, y, z); 076 } 077 } 078 079 /** 080 * A handy shortcut for firing the various liquid events 081 * 082 * @param event 083 */ 084 public static final void fireEvent(LiquidEvent event) { 085 MinecraftForge.EVENT_BUS.post(event); 086 } 087 }