MenuClick
Namespace Mc.Scripting.Inventories · Kind class (sealed)
public sealed class MenuClickA 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.
Properties
Section titled “Properties”| 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. |
Allowed
Section titled “Allowed”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).
Button
Section titled “Button”public int Button { get; }The raw button of the click packet.
Cancelled
Section titled “Cancelled”public bool Cancelled { get; set; }Whether the click is cancelled for good (MenuClick.Cancel or setting this).
Clicked
Section titled “Clicked”public ItemStack Clicked { get; }The stack in the clicked slot (before the click).
Cursor
Section titled “Cursor”public ItemStack Cursor { get; }The stack the player holds on the cursor (before the click).
IsTopInventory
Section titled “IsTopInventory”public bool IsTopInventory { get; }Whether the click is on one of the menu’s own slots.
public Menu Menu { get; }The menu.
Player
Section titled “Player”public Player Player { get; }The player who clicked.
PlayerSlot
Section titled “PlayerSlot”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.
Methods
Section titled “Methods”| 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.
Cancel
Section titled “Cancel”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.
SetClicked
Section titled “SetClicked”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. |
SetCursor
Section titled “SetCursor”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. |
See also
Section titled “See also”ItemStack · Menu · MenuClickType · Player