Skip to content

EnchantItemEvent

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

public ref struct EnchantItemEvent : IEvent

A player is enchanting an item at an enchanting table. Cancel to refuse.

Id 268
Key mc:enchant_item
Cancellable yes
Fired by the engine yes
Field Type Handlers may write Description
Player player no (readonly) The player.
Item item no (readonly) The item being enchanted.
Option int no (readonly) The chosen option (0-2).
Cost int no (readonly) Levels charged.

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

Member Description
EnchantItemEvent(Player player, ItemView item, int option, int cost) Creates the event (for firing it from a plugin; native code builds its own).
public EnchantItemEvent(Player player, ItemView item, int option, int cost)

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
item ItemView
option int
cost int
Member Description
bool Cancelled { get; set; } Cancelling stops lower-priority handlers (unless they opt in) and the action itself.
int Cost { get; } Levels charged.
ItemView Item { get; } The item being enchanted.
int Option { get; } The chosen option (0-2).
Player Player { get; } The player.
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 int Cost { get; }

Levels charged.

public ItemView Item { get; }

The item being enchanted.

public int Option { get; }

The chosen option (0-2).

public Player Player { get; }

The player.

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.

IEvent · ItemView · Player