MCPlayerInteractEvent

This event is the superclass of all other PlayerInteract events. Generally, you want to use the subtypes of this event.

The event is not cancelable.

The event does not have a result.

Importing the class

It might be required for you to import the package if you encounter any issues (like casting an Array), so better be safe than sorry and add the import at the very top of the file.

ZenScript
Copy
import crafttweaker.api.event.entity.player.interact.MCPlayerInteractEvent;

Extending MCPlayerEvent

MCPlayerInteractEvent extends MCPlayerEvent. That means all methods available in MCPlayerEvent are also available in MCPlayerInteractEvent

Methods

getBlockPos

If the interaction was on an entity, will be a BlockPos centered on the entity. If the interaction was on a block, will be the position of that block. Otherwise, will be a BlockPos centered on the player.

Return Type: BlockPos

ZenScript
Copy
MCPlayerInteractEvent.getBlockPos() as BlockPos
myMCPlayerInteractEvent.getBlockPos();

getFace

The face involved in this interaction. For all non-block interactions, this will return null

Return Type: Direction?

ZenScript
Copy
MCPlayerInteractEvent.getFace() as Direction?
myMCPlayerInteractEvent.getFace();

getItemStack

The stack involved in this interaction. May be empty, but will never be null.

Return Type: IItemStack

ZenScript
Copy
MCPlayerInteractEvent.getItemStack() as IItemStack
myMCPlayerInteractEvent.getItemStack();

Properties

NameTypeHas GetterHas Setter
blockPosBlockPostruefalse
faceDirection?truefalse
stos przedmiotówIItemStacktruefalse