Skip to content

PlayerInteractBlockEvent

Namespace Mc.Scripting.Events · Kind struct (ref)

public ref struct PlayerInteractBlockEvent : IEvent

A player right-clicked a block (fired after PlayerInteract). Cancel to stop the block interaction and item use.

Id 16
Key mc:player_interact_block
Cancellable yes
Fired by the engine yes
Field Type Handlers may write Description
Player player no (readonly) The player.
Pos BlockPos no (readonly) The clicked block.
Face byte no (readonly) The clicked face (BlockFace).
Hand byte no (readonly) The hand (Hand).
Item item no (readonly) The item in that hand.

Set e.Cancelled = true in a handler to cancel it; lower-priority handlers are skipped unless they subscribed with receiveCancelled: true.

Member Description
PlayerInteractBlockEvent(Player player, BlockPos pos, byte face, byte hand, ItemView item) Creates the event (for firing it from a plugin; native code builds its own).
public PlayerInteractBlockEvent(Player player, BlockPos pos, byte face, byte hand, ItemView item)

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
pos BlockPos
face byte
hand byte
item ItemView
Member Description
bool Cancelled { get; set; } Cancelling stops lower-priority handlers (unless they opt in) and the action itself.
byte Face { get; } The clicked face (BlockFace).
byte Hand { get; } The hand (Hand).
ItemView Item { get; } The item in that hand.
Player Player { get; } The player.
BlockPos Pos { get; } The clicked block.
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.
public bool Cancelled { get; set; }

Cancelling stops lower-priority handlers (unless they opt in) and the action itself.

public byte Face { get; }

The clicked face (BlockFace).

public byte Hand { get; }

The hand (Hand).

public ItemView Item { get; }

The item in that hand.

public Player Player { get; }

The player.

public BlockPos Pos { get; }

The clicked block.

public static ushort CatalogueId { get; }

Catalogue id (stable ABI).

public static bool IsCancellable { get; }

Whether handlers can cancel the event.

public static string Key { get; }

Registry key of the event.

BlockPos · Hand · IEvent · ItemView · Player