PlayerInteractEvent
This fires each time you interact with a block in the world.
Cancellable = false
Parameter
PlayerInteractEvent
Properties
Action
-
LEFT_CLICK_BLOCK
-
RIGHT_CLICK_BLOCK
Methods
Action
Returns current action as shown above.
Player
Returns EntityPlayerSP.
World
Returns WorldClient.
Block position
Returns BlockPos.
Facing
Returns EnumFacing.
Example
/*
Sends a message when you right-click a chest.
*/
@EventTarget
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getAction() != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) return;
final BlockPos blockPos = event.getPos();
final TileEntity tileEntity = mc.theWorld.getTileEntity(blockPos);
if (tileEntity instanceof TileEntityChest) {
Meowtils.addMessage("Right clicked chest!");
}
}