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.
import crafttweaker.neoforge.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 BlockPosmyPlayerInteractEvent.blockPos
Return Type:
BlockPos
Getter
// PlayerInteractEvent.cancellationResult as InteractionResultmyPlayerInteractEvent.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
Note that this only has an effect on RightClickBlockEvent, RightClickItemEvent, EntityInteractEvent.
myPlayerInteractEvent.cancellationResult = myInteractionResult;
Parameters:
result: InteractionResult
Type: InteractionResult
Getter
Getter
// PlayerInteractEvent.entity as LivingEntitymyPlayerInteractEvent.entity
Return Type:
LivingEntity
Getter
Getter
// PlayerInteractEvent.hand as InteractionHandmyPlayerInteractEvent.hand
Return Type:
InteractionHand
Getter
// PlayerInteractEvent.hasResult as boolmyPlayerInteractEvent.hasResult
Return Type:
bool
hasResult() as bool
// 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 IItemStackmyPlayerInteractEvent.itemStack
Return Type:
IItemStack
Getter
// PlayerInteractEvent.result as EventResultmyPlayerInteractEvent.result
Return Type:
EventResult
Setter
myPlayerInteractEvent.result = myResult;
Parameters:
result: EventResult
Type: EventResult
result() as Result
result(result as Result)
myPlayerInteractEvent.result(myResult);
Parameters:
result: EventResult
Type: EventResult
setAllow()
sets the event's result to script.zs
allow
// PlayerInteractEvent.setAllow();myPlayerInteractEvent.setAllow();
setDefault()
sets the event's result to script.zs
default
// PlayerInteractEvent.setDefault();myPlayerInteractEvent.setDefault();
setDeny()
sets the event's result to script.zs
deny
// PlayerInteractEvent.setDeny();myPlayerInteractEvent.setDeny();