Skip to content

MenuClick

Namespace Mc.Scripting.Inventories · Kind class (sealed)

public sealed class MenuClick

A click in a MenuClick.Menu. A menu is locked: a click that could move items out of the menu or into it (a slot of the menu, shift click, double click, number key, the off hand key, the drop key, a middle click) is denied and the client is resynced unless the handler calls MenuClick.Allow; MenuClick.Cancel always denies. Clicks that only touch the player’s own inventory slots pass unless a handler cancels them (or the menu locks the player inventory too). The object is valid during the handler only.

Member Description
bool Allowed { get; } Whether the click will be processed (set by MenuClick.Allow; false by default for a click on the menu’s own slots).
int Button { get; } The raw button of the click packet.
bool Cancelled { get; set; } Whether the click is cancelled for good (MenuClick.Cancel or setting this).
ItemStack Clicked { get; } The stack in the clicked slot (before the click).
ItemStack Cursor { get; } The stack the player holds on the cursor (before the click).
bool IsTopInventory { get; } Whether the click is on one of the menu’s own slots.
Menu Menu { get; } The menu.
Player Player { get; } The player who clicked.
int PlayerSlot { get; } For a click on the player’s own slots: the slot in PlayerInventory numbering; otherwise -1.
int Slot { get; } The clicked slot in the menu’s numbering: 0 to Menu.Size - 1 are the menu’s own slots, then the player’s 27 main and 9 hotbar slots; -999 outside the window.
MenuClickType Type { get; } How the player clicked.
public bool Allowed { get; }

Whether the click will be processed (set by MenuClick.Allow; false by default for a click on the menu’s own slots).

public int Button { get; }

The raw button of the click packet.

public bool Cancelled { get; set; }

Whether the click is cancelled for good (MenuClick.Cancel or setting this).

public ItemStack Clicked { get; }

The stack in the clicked slot (before the click).

public ItemStack Cursor { get; }

The stack the player holds on the cursor (before the click).

public bool IsTopInventory { get; }

Whether the click is on one of the menu’s own slots.

public Menu Menu { get; }

The menu.

public Player Player { get; }

The player who clicked.

public int PlayerSlot { get; }

For a click on the player’s own slots: the slot in PlayerInventory numbering; otherwise -1.

public int Slot { get; }

The clicked slot in the menu’s numbering: 0 to Menu.Size - 1 are the menu’s own slots, then the player’s 27 main and 9 hotbar slots; -999 outside the window.

public MenuClickType Type { get; }

How the player clicked.

Member Description
void Allow() Lets the click change items like it would in a chest (take the stack out of the menu, put one in, shift click …).
void Cancel() Denies the click: nothing changes and the client is resynced (also for clicks that would pass by default).
void Close() Closes the menu for the player after the click.
void SetClicked(ItemStack stack) Replaces the stack in the clicked slot (a slot of the menu or one of the player’s).
void SetCursor(ItemStack stack) Replaces the stack on the player’s cursor (the client is resynced after the click).
public void Allow()

Lets the click change items like it would in a chest (take the stack out of the menu, put one in, shift click …). The server only does what vanilla does.

public void Cancel()

Denies the click: nothing changes and the client is resynced (also for clicks that would pass by default).

public void Close()

Closes the menu for the player after the click.

public void SetClicked(ItemStack stack)

Replaces the stack in the clicked slot (a slot of the menu or one of the player’s).

Parameters

Name Type Description
stack ItemStack The new stack.
public void SetCursor(ItemStack stack)

Replaces the stack on the player’s cursor (the client is resynced after the click).

Parameters

Name Type Description
stack ItemStack The new cursor stack.

ItemStack · Menu · MenuClickType · Player