MCPlayerInteractEvent

Link to 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.

Импорт класса

Link to импорт-класса

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

Link to extending-mcplayerevent

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

Name: 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();

Link to getCancellationResult

Name: getCancellationResult

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: ActionResultType

ZenScript
Copy
// MCPlayerInteractEvent.getCancellationResult() as ActionResultType

myMCPlayerInteractEvent.getCancellationResult();

Name: 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();

Name: getHand

Return Type: MCHand

ZenScript
Copy
// MCPlayerInteractEvent.getHand() as MCHand

myMCPlayerInteractEvent.getHand();

Name: 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();

Link to setCancellationResult

Name: setCancellationResult

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

ZenScript
Copy
MCPlayerInteractEvent.setCancellationResult(result as ActionResultType) as void
ПараметрТипОписание
Параметр
result
Тип
ActionResultType
Описание
No Description Provided

Свойства

Link to свойства

НазваниеТипИмеет GetterИмеет SetterОписание
Название
blockPos
Тип
BlockPos
Имеет Getter
true
Имеет Setter
false
Описание
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.
Название
cancellationResult
Тип
ActionResultType
Имеет Getter
true
Имеет Setter
true
Описание
Название
face
Тип
Direction?
Имеет Getter
true
Имеет Setter
false
Описание
The face involved in this interaction.
For all non-block interactions, this will return null
Название
hand
Тип
MCHand
Имеет Getter
true
Имеет Setter
false
Описание
No Description Provided
Название
элемент Стек
Тип
IItemStack
Имеет Getter
true
Имеет Setter
false
Описание
The stack involved in this interaction.
May be empty, but will never be null.