PlayerInteractEvent

Importing the class

If you need to reference this type directly, like when casting an Array, or as a parameter, you will need to import it. Simply add the import at the top of the file.

script.zs
import crafttweaker.forge.api.interact.PlayerInteractEvent;

Description

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

Extends

PlayerInteractEvent extends PlayerEvent.

Members

Getter
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.
script.zs
// PlayerInteractEvent.blockPos as BlockPos
myPlayerInteractEvent.blockPos

Return Type: BlockPos

cancel()
Cancels the event. Same as setCanceled(true)
script.zs
// PlayerInteractEvent.cancel();
myPlayerInteractEvent.cancel();
Getter
script.zs
// PlayerInteractEvent.cancelable as bool
myPlayerInteractEvent.cancelable

Return Type: bool

cancelable() as bool
script.zs
// PlayerInteractEvent.cancelable() as bool;
myPlayerInteractEvent.cancelable();

Return Type: bool

Getter
script.zs
// PlayerInteractEvent.canceled as bool
myPlayerInteractEvent.canceled

Return Type: bool

Setter
script.zs
// PlayerInteractEvent.canceled = (cancel as bool);
myPlayerInteractEvent.canceled = myBool;

Parameters:

cancel Type: bool
canceled() as bool
script.zs
// PlayerInteractEvent.canceled() as bool;
myPlayerInteractEvent.canceled();

Return Type: bool

canceled(cancel as bool)
script.zs
// PlayerInteractEvent.canceled(cancel as bool);
myPlayerInteractEvent.canceled(myBool);

Parameters:

cancel Type: bool
Getter
script.zs
// PlayerInteractEvent.cancellationResult as InteractionResult
myPlayerInteractEvent.cancellationResult

Return Type: InteractionResult

Setter
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.
script.zs
// PlayerInteractEvent.cancellationResult = (result as InteractionResult);
myPlayerInteractEvent.cancellationResult = myInteractionResult;

Parameters:

Getter
script.zs
// PlayerInteractEvent.entity as Player
myPlayerInteractEvent.entity

Return Type: Player

Getter
script.zs
// PlayerInteractEvent.entity as LivingEntity
myPlayerInteractEvent.entity

Return Type: LivingEntity

Getter
script.zs
// PlayerInteractEvent.entity as Entity
myPlayerInteractEvent.entity

Return Type: Entity

Getter
The face involved in this interaction. For all non-block interactions, this will return null
script.zs
// PlayerInteractEvent.face as Direction
myPlayerInteractEvent.face

Return Type: Direction

Getter
script.zs
// PlayerInteractEvent.hand as InteractionHand
myPlayerInteractEvent.hand

Return Type: InteractionHand

Getter
script.zs
// PlayerInteractEvent.hasResult as bool
myPlayerInteractEvent.hasResult

Return Type: bool

hasResult() as bool
script.zs
// PlayerInteractEvent.hasResult() as bool;
myPlayerInteractEvent.hasResult();

Return Type: bool

Getter
The stack involved in this interaction. May be empty, but will never be null.
script.zs
// PlayerInteractEvent.itemStack as IItemStack
myPlayerInteractEvent.itemStack

Return Type: IItemStack

Getter
script.zs
// PlayerInteractEvent.result as Result
myPlayerInteractEvent.result

Return Type: EventResult

Setter
script.zs
// PlayerInteractEvent.result = (result as Result);
myPlayerInteractEvent.result = myResult;

Parameters:

result Type: EventResult
result() as Result
script.zs
// PlayerInteractEvent.result() as Result;
myPlayerInteractEvent.result();

Return Type: EventResult

result(result as Result)
script.zs
// PlayerInteractEvent.result(result as Result);
myPlayerInteractEvent.result(myResult);

Parameters:

result Type: EventResult
setAllow()
sets the event's result to allow
script.zs
// PlayerInteractEvent.setAllow();
myPlayerInteractEvent.setAllow();
setDefault()
sets the event's result to default
script.zs
// PlayerInteractEvent.setDefault();
myPlayerInteractEvent.setDefault();
setDeny()
sets the event's result to deny
script.zs
// PlayerInteractEvent.setDeny();
myPlayerInteractEvent.setDeny();