001    package net.minecraftforge.liquids;
002    
003    import net.minecraft.tileentity.TileEntity;
004    import net.minecraft.world.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        {
032            public LiquidMotionEvent(LiquidStack liquid, World world, int x, int y, int z)
033            {
034                super(liquid, world, x, y, z);
035            }
036        }
037    
038        /**
039         * Mods should fire this event when a liquid is {@link ILiquidTank#fill(LiquidStack, boolean)} their tank implementation.
040         * {@link LiquidTank} does.
041         *
042         * @author cpw
043         *
044         */
045        public static class LiquidFillingEvent extends LiquidEvent
046        {
047            public final ILiquidTank tank;
048    
049            public LiquidFillingEvent(LiquidStack liquid, World world, int x, int y, int z, ILiquidTank tank)
050            {
051                super(liquid, world, x, y, z);
052                this.tank = tank;
053            }
054        }
055    
056        /**
057         * Mods should fire this event when a liquid is {@link ILiquidTank#drain(int, boolean)} from their tank.
058         * @author cpw
059         *
060         */
061        public static class LiquidDrainingEvent extends LiquidEvent
062        {
063            public final ILiquidTank tank;
064    
065            public LiquidDrainingEvent(LiquidStack liquid, World world, int x, int y, int z, ILiquidTank tank)
066            {
067                super(liquid, world, x, y, z);
068                this.tank = tank;
069            }
070        }
071    
072    
073        /**
074         * Mods should fire this event when a liquid "spills", for example, if a block containing liquid is broken.
075         *
076         * @author cpw
077         *
078         */
079        public static class LiquidSpilledEvent extends LiquidEvent
080        {
081            public LiquidSpilledEvent(LiquidStack liquid, World world, int x, int y, int z)
082            {
083                super(liquid, world, x, y, z);
084            }
085        }
086    
087        /**
088         * A handy shortcut for firing the various liquid events
089         *
090         * @param event
091         */
092        public static final void fireEvent(LiquidEvent event)
093        {
094            MinecraftForge.EVENT_BUS.post(event);
095        }
096    }