2012-09-27 04:18:18 +00:00
|
|
|
package net.minecraftforge.event.entity.player;
|
|
|
|
|
2012-12-13 05:58:35 +00:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.world.World;
|
2012-09-27 04:18:18 +00:00
|
|
|
import net.minecraftforge.event.Cancelable;
|
|
|
|
import net.minecraftforge.event.Event;
|
|
|
|
import static net.minecraftforge.event.Event.Result;
|
|
|
|
import static net.minecraftforge.event.Event.Result.*;
|
|
|
|
|
|
|
|
@Cancelable
|
|
|
|
public class PlayerInteractEvent extends PlayerEvent
|
|
|
|
{
|
|
|
|
public static enum Action
|
|
|
|
{
|
|
|
|
RIGHT_CLICK_AIR,
|
|
|
|
RIGHT_CLICK_BLOCK,
|
|
|
|
LEFT_CLICK_BLOCK
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Action action;
|
|
|
|
public final int x;
|
|
|
|
public final int y;
|
|
|
|
public final int z;
|
|
|
|
public final int face;
|
|
|
|
|
|
|
|
public Result useBlock = DEFAULT;
|
|
|
|
public Result useItem = DEFAULT;
|
|
|
|
|
|
|
|
public PlayerInteractEvent(EntityPlayer player, Action action, int x, int y, int z, int face)
|
|
|
|
{
|
|
|
|
super(player);
|
|
|
|
this.action = action;
|
|
|
|
this.x = x;
|
|
|
|
this.y = y;
|
|
|
|
this.z = z;
|
|
|
|
this.face = face;
|
|
|
|
if (face == -1) useBlock = DENY;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setCanceled(boolean cancel)
|
|
|
|
{
|
2012-11-13 01:34:26 +00:00
|
|
|
super.setCanceled(cancel);
|
2012-09-27 04:18:18 +00:00
|
|
|
useBlock = (cancel ? DENY : useBlock == DENY ? DEFAULT : useBlock);
|
|
|
|
useItem = (cancel ? DENY : useItem == DENY ? DEFAULT : useItem);
|
|
|
|
}
|
|
|
|
}
|