Skip to content

InventoryOpenEvent

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

public ref struct InventoryOpenEvent : IEvent

A player is about to open a container (chest, furnace, crafting table, …). Cancel to keep it closed.

Id 260
Key mc:inventory_open
Cancellable yes
Fired by the engine yes
Field Type Handlers may write Description
Player player no (readonly) The player.
Kind enum:InventoryKind no (readonly) The container kind.
HasPos bool no (readonly) Whether the container is a block.
Pos BlockPos no (readonly) The block position.

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

Member Description
InventoryOpenEvent(Player player, InventoryKind kind, bool hasPos, BlockPos pos) Creates the event (for firing it from a plugin; native code builds its own).
public InventoryOpenEvent(Player player, InventoryKind kind, bool hasPos, BlockPos pos)

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
kind InventoryKind
hasPos bool
pos BlockPos
Member Description
bool Cancelled { get; set; } Cancelling stops lower-priority handlers (unless they opt in) and the action itself.
bool HasPos { get; } Whether the container is a block.
InventoryKind Kind { get; } The container kind.
Player Player { get; } The player.
BlockPos Pos { get; } The block position.
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 bool HasPos { get; }

Whether the container is a block.

public InventoryKind Kind { get; }

The container kind.

public Player Player { get; }

The player.

public BlockPos Pos { get; }

The block position.

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 · IEvent · InventoryKind · Player