Skip to content

CustomItemUseEvent

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

public ref struct CustomItemUseEvent : IEvent

A player used a custom item (right click in the air or on a block). Fired by the content layer after PlayerInteract. Cancel to stop the item’s own handler and the default action.

Id 272
Key mc:custom_item_use
Cancellable yes
Fired by the engine yes
Field Type Handlers may write Description
Player player no (readonly) The player.
CustomId Utf8String no (readonly) The id of the custom item, “myplugin:ruby”.
Hand enum:Hand no (readonly) The hand.
Item item no (readonly) The item stack.
HasBlock bool no (readonly) Whether the click was on a block.
Pos BlockPos no (readonly) The clicked block (only when has_block).
Face enum:BlockFace no (readonly) The clicked face (only when has_block).

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

Member Description
Constructor Creates the event (for firing it from a plugin; native code builds its own).
public CustomItemUseEvent(Player player, Utf8String customId, Hand hand, ItemView item, bool hasBlock, BlockPos pos, BlockFace face)

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
customId Utf8String
hand Hand
item ItemView
hasBlock bool
pos BlockPos
face BlockFace
Member Description
bool Cancelled { get; set; } Cancelling stops lower-priority handlers (unless they opt in) and the action itself.
Utf8String CustomId { get; } The id of the custom item, “myplugin:ruby”.
BlockFace Face { get; } The clicked face (only when has_block).
Hand Hand { get; } The hand.
bool HasBlock { get; } Whether the click was on a block.
ItemView Item { get; } The item stack.
Player Player { get; } The player.
BlockPos Pos { get; } The clicked block (only when has_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 Utf8String CustomId { get; }

The id of the custom item, “myplugin:ruby”.

public BlockFace Face { get; }

The clicked face (only when has_block).

public Hand Hand { get; }

The hand.

public bool HasBlock { get; }

Whether the click was on a block.

public ItemView Item { get; }

The item stack.

public Player Player { get; }

The player.

public BlockPos Pos { get; }

The clicked block (only when has_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.

BlockFace · BlockPos · Hand · IEvent · ItemView · Player · Utf8String