2012-09-27 04:18:18 +00:00
|
|
|
package net.minecraftforge.event.entity.player;
|
|
|
|
|
2014-06-02 22:49:11 +00:00
|
|
|
import static cpw.mods.fml.common.eventhandler.Event.Result.DEFAULT;
|
|
|
|
import static cpw.mods.fml.common.eventhandler.Event.Result.DENY;
|
2012-12-13 05:58:35 +00:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2014-06-02 22:49:11 +00:00
|
|
|
import net.minecraft.world.World;
|
|
|
|
import cpw.mods.fml.common.eventhandler.Cancelable;
|
2012-09-27 04:18:18 +00:00
|
|
|
|
2014-07-06 20:07:49 +00:00
|
|
|
/**
|
|
|
|
* PlayerInteractEvent is fired when a player interacts in some way.
|
|
|
|
* <br>
|
|
|
|
* This event is fired whenever a player interacts in
|
|
|
|
* Minecraft#func_147121_ag(),
|
|
|
|
* NetHandlerPlayServer#processPlayerBlockPlacement(C08PacketPlayerBlockPlacement),
|
|
|
|
* ItemInWorldManager#activateBlockOrUseItem(EntityPlayer, World, ItemStack, int, int, int, int, float, float, float),
|
|
|
|
* ItemInWorldManager#onBlockClicked(int, int, int, int). <br>
|
|
|
|
* <br>
|
|
|
|
* This event is fired via the {@link ForgeEventFactory#onPlayerInteract(EntityPlayer, Action, int, int, int, int)}.
|
|
|
|
* <br>
|
|
|
|
* {@link #action} contains the Action the player performed durin this interaction. <br>
|
|
|
|
* {@link #x} contains the x-coordinate of where this event occurred. <br>
|
|
|
|
* {@link #y} contains the y-coordinate of where this event occurred. <br>
|
|
|
|
* {@link #z} contains the z-coordinate of where this event occurred. <br>
|
|
|
|
* {@link #face} contains the face of the block that was interacted with. <br>
|
|
|
|
* {@link #world} contains the world in which this event is occurring. <br>
|
|
|
|
* <br>
|
|
|
|
* This event is {@link Cancelable}.<br>
|
|
|
|
* If this event is canceled, the player does not interact.<br>
|
|
|
|
* <br>
|
|
|
|
* This event does not have a result. {@link HasResult}<br>
|
|
|
|
* <br>
|
|
|
|
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.
|
|
|
|
**/
|
2012-09-27 04:18:18 +00:00
|
|
|
@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;
|
2014-06-02 22:49:11 +00:00
|
|
|
public final World world;
|
2012-09-27 04:18:18 +00:00
|
|
|
|
|
|
|
public Result useBlock = DEFAULT;
|
|
|
|
public Result useItem = DEFAULT;
|
2014-06-02 22:49:11 +00:00
|
|
|
|
|
|
|
@Deprecated
|
2012-09-27 04:18:18 +00:00
|
|
|
public PlayerInteractEvent(EntityPlayer player, Action action, int x, int y, int z, int face)
|
2014-06-02 22:49:11 +00:00
|
|
|
{
|
|
|
|
this(player, action, x, y, z, face, player.worldObj);
|
|
|
|
}
|
|
|
|
|
|
|
|
public PlayerInteractEvent(EntityPlayer player, Action action, int x, int y, int z, int face, World world)
|
2012-09-27 04:18:18 +00:00
|
|
|
{
|
|
|
|
super(player);
|
|
|
|
this.action = action;
|
|
|
|
this.x = x;
|
|
|
|
this.y = y;
|
|
|
|
this.z = z;
|
|
|
|
this.face = face;
|
|
|
|
if (face == -1) useBlock = DENY;
|
2014-06-02 22:49:11 +00:00
|
|
|
this.world = world;
|
2012-09-27 04:18:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@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);
|
|
|
|
}
|
|
|
|
}
|