PlayerInteractEvent
Namespace Mc.Scripting.Events · Kind struct (ref)
public ref struct PlayerInteractEvent : IEventA player clicked (left or right, air or block). Cancel to stop the default action: block breaking start, block use, item use.
| Id | 118 |
| Key | mc:player_interact |
| Cancellable | yes |
| Fired by the engine | yes |
| Field | Type | Handlers may write | Description |
|---|---|---|---|
Player |
player |
no (readonly) | The player. |
Action |
enum:InteractAction |
no (readonly) | What was clicked. |
Hand |
enum:Hand |
no (readonly) | The hand. |
Item |
item |
no (readonly) | The item in that hand. |
Pos |
BlockPos |
no (readonly) | The clicked block (only for block actions). |
Face |
enum:BlockFace |
no (readonly) | The clicked face (only for block actions). |
HasBlock |
bool |
no (readonly) | Whether pos/face are valid. |
Set e.Cancelled = true in a handler to cancel it; lower-priority handlers are skipped unless they subscribed with receiveCancelled: true.
Constructors
Section titled “Constructors”| Member | Description |
|---|---|
Constructor |
Creates the event (for firing it from a plugin; native code builds its own). |
Constructor
Section titled “Constructor”public PlayerInteractEvent(Player player, InteractAction action, Hand hand, ItemView item, BlockPos pos, BlockFace face, bool hasBlock)Creates the event (for firing it from a plugin; native code builds its own). Signature of API 1.0.
Parameters
| Name | Type | Description |
|---|---|---|
player |
Player |
|
action |
InteractAction |
|
hand |
Hand |
|
item |
ItemView |
|
pos |
BlockPos |
|
face |
BlockFace |
|
hasBlock |
bool |
Properties
Section titled “Properties”| Member | Description |
|---|---|
InteractAction Action { get; } |
What was clicked. |
bool Cancelled { get; set; } |
Cancelling stops lower-priority handlers (unless they opt in) and the action itself. |
BlockFace Face { get; } |
The clicked face (only for block actions). |
Hand Hand { get; } |
The hand. |
bool HasBlock { get; } |
Whether pos/face are valid. |
ItemView Item { get; } |
The item in that hand. |
Player Player { get; } |
The player. |
BlockPos Pos { get; } |
The clicked block (only for block actions). |
static ushort CatalogueId { get; } |
Catalogue id (stable ABI). |
static bool IsCancellable { get; } |
Whether handlers can cancel the event. |
static string Key { get; } |
Registry key of the event. |
Action
Section titled “Action”public InteractAction Action { get; }What was clicked.
Cancelled
Section titled “Cancelled”public bool Cancelled { get; set; }Cancelling stops lower-priority handlers (unless they opt in) and the action itself.
public BlockFace Face { get; }The clicked face (only for block actions).
public Hand Hand { get; }The hand.
HasBlock
Section titled “HasBlock”public bool HasBlock { get; }Whether pos/face are valid.
public ItemView Item { get; }The item in that hand.
Player
Section titled “Player”public Player Player { get; }The player.
public BlockPos Pos { get; }The clicked block (only for block actions).
CatalogueId
Section titled “CatalogueId”public static ushort CatalogueId { get; }Catalogue id (stable ABI).
IsCancellable
Section titled “IsCancellable”public static bool IsCancellable { get; }Whether handlers can cancel the event.
public static string Key { get; }Registry key of the event.
See also
Section titled “See also”BlockFace · BlockPos · Hand · IEvent · InteractAction · ItemView · Player