PlayerInteractEvent
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.
import crafttweaker.api.event.entity.player.interact.PlayerInteractEvent;
Extending PlayerEvent
PlayerInteractEvent extends PlayerEvent. That means all methods available in PlayerEvent are also available in PlayerInteractEvent
Methods
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
// PlayerInteractEvent.getBlockPos() as BlockPos
myPlayerInteractEvent.getBlockPos();
Returns: The EnumActionResult that will be returned to vanilla if the event is cancelled, instead of calling the relevant
method of the event. By default, this is PASS, meaning cancelled events will cause
the client to keep trying more interactions until something works.
Return Type: InteractionResult
// PlayerInteractEvent.getCancellationResult() as InteractionResult
myPlayerInteractEvent.getCancellationResult();
The face involved in this interaction. For all non-block interactions, this will return null
Return Type: Direction
// PlayerInteractEvent.getFace() as Direction
myPlayerInteractEvent.getFace();
Return Type: InteractionHand
// PlayerInteractEvent.getHand() as InteractionHand
myPlayerInteractEvent.getHand();
The stack involved in this interaction. May be empty, but will never be null.
Return Type: IItemStack
// PlayerInteractEvent.getItemStack() as IItemStack
myPlayerInteractEvent.getItemStack();
Set the EnumActionResult that will be returned to vanilla if the event is cancelled, instead of calling the relevant method of the event.
Note that this only has an effect on RightClickBlockEvent, RightClickItemEvent, EntityInteractEvent.
Return Type: void
PlayerInteractEvent.setCancellationResult(result as InteractionResult) as void
Parameter | Type | Description |
---|---|---|
Parameter result | Type InteractionResult | Description No Description Provided |
Properties
Name | Type | Has Getter | Has Setter | Description |
---|---|---|---|---|
Name blockPos | Type BlockPos | Has Getter true | Has Setter false | Description 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. |
Name cancellationResult | Type InteractionResult | Has Getter true | Has Setter true | Description |
Name face | Type Direction | Has Getter true | Has Setter false | Description The face involved in this interaction. For all non-block interactions, this will return null |
Name hand | Type InteractionHand | Has Getter true | Has Setter false | Description No Description Provided |
Name itemStack | Type IItemStack | Has Getter true | Has Setter false | Description The stack involved in this interaction. May be empty, but will never be null. |