    001package net.minecraftforge.event.entity.player;
    002
    003import net.minecraft.entity.player.EntityPlayer;
    004import net.minecraft.world.World;
    005import net.minecraftforge.event.Cancelable;
    006import net.minecraftforge.event.Event;
    007import static net.minecraftforge.event.Event.Result;
    008import static net.minecraftforge.event.Event.Result.*;
    009
    010@Cancelable
    011public 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        super.setCanceled(cancel);
    044        useBlock = (cancel ? DENY : useBlock == DENY ? DEFAULT : useBlock);
    045        useItem = (cancel ? DENY : useItem == DENY ? DEFAULT : useItem);
    046    }
    047}