    001    package net.minecraftforge.event.entity.player;
    002
    003    import net.minecraft.src.EntityPlayer;
    004    import net.minecraft.src.World;
    005    import net.minecraftforge.event.Cancelable;
    006    import net.minecraftforge.event.Event;
    007    import static net.minecraftforge.event.Event.Result;
    008    import static net.minecraftforge.event.Event.Result.*;
    009
    010    @Cancelable
    011    public class PlayerInteractEvent extends PlayerEvent
    012    {
    013        public static enum Action
    014        {
    015            RIGHT_CLICK_AIR,
    016            RIGHT_CLICK_BLOCK,
    017            LEFT_CLICK_BLOCK
    018        }
    019
    020        public final Action action;
    021        public final int x;
    022        public final int y;
    023        public final int z;
    024        public final int face;
    025
    026        public Result useBlock = DEFAULT;
    027        public Result useItem = DEFAULT;
    028
    029        public PlayerInteractEvent(EntityPlayer player, Action action, int x, int y, int z, int face)
    030        {
    031            super(player);
    032            this.action = action;
    033            this.x = x;
    034            this.y = y;
    035            this.z = z;
    036            this.face = face;
    037            if (face == -1) useBlock = DENY;
    038        }
    039
    040        @Override
    041        public void setCanceled(boolean cancel)
    042        {
    043            useBlock = (cancel ? DENY : useBlock == DENY ? DEFAULT : useBlock);
    044            useItem = (cancel ? DENY : useItem == DENY ? DEFAULT : useItem);
    045        }
    046    }