Skip to content

PlayerSwapHandsEvent

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

public ref struct PlayerSwapHandsEvent : IEvent

A player swapped the main hand and off hand items (F key). Cancel to keep them.

Id 114
Key mc:player_swap_hands
Cancellable yes
Fired by the engine yes
Field Type Handlers may write Description
Player player no (readonly) The player.
MainHand item no (readonly) The item that moves to the off hand.
OffHand item no (readonly) The item that moves to the main hand.

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

Member Description
PlayerSwapHandsEvent(Player player, ItemView mainHand, ItemView offHand) Creates the event (for firing it from a plugin; native code builds its own).
public PlayerSwapHandsEvent(Player player, ItemView mainHand, ItemView offHand)

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
mainHand ItemView
offHand ItemView
Member Description
bool Cancelled { get; set; } Cancelling stops lower-priority handlers (unless they opt in) and the action itself.
ItemView MainHand { get; } The item that moves to the off hand.
ItemView OffHand { get; } The item that moves to the main hand.
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 ItemView MainHand { get; }

The item that moves to the off hand.

public ItemView OffHand { get; }

The item that moves to the main hand.

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