PlayerInventory
Namespace Mc.Scripting.Inventories · Kind class (sealed)
public sealed class PlayerInventory : EngineInventoryThe inventory of a player: 41 slots numbered like the game’s own inventory container, plus the cursor. Slots 0-8 are the hotbar, 9-35 the main inventory, 36 to 39 the armor (boots, leggings, chestplate, helmet) and 40 the off hand. A stale player (one who left) has no slots: reads are empty and writes are refused.
Fields
Section titled “Fields”| Member | Description |
|---|---|
const int BootsSlot = 36 |
The boots slot. |
const int ChestplateSlot = 38 |
The chestplate slot. |
const int FirstMainSlot = 9 |
First slot of the main inventory (below the hotbar). |
const int HelmetSlot = 39 |
The helmet slot. |
const int LeggingsSlot = 37 |
The leggings slot. |
const int OffHandSlot = 40 |
The off hand slot. |
const int SlotCount = 41 |
Number of slots. |
BootsSlot
Section titled “BootsSlot”public const int BootsSlot = 36;The boots slot.
ChestplateSlot
Section titled “ChestplateSlot”public const int ChestplateSlot = 38;The chestplate slot.
FirstMainSlot
Section titled “FirstMainSlot”public const int FirstMainSlot = 9;First slot of the main inventory (below the hotbar).
HelmetSlot
Section titled “HelmetSlot”public const int HelmetSlot = 39;The helmet slot.
LeggingsSlot
Section titled “LeggingsSlot”public const int LeggingsSlot = 37;The leggings slot.
OffHandSlot
Section titled “OffHandSlot”public const int OffHandSlot = 40;The off hand slot.
SlotCount
Section titled “SlotCount”public const int SlotCount = 41;Number of slots.
Properties
Section titled “Properties”| Member | Description |
|---|---|
ItemStack Boots { get; set; } |
The boots. |
ItemStack Chestplate { get; set; } |
The chestplate. |
ItemStack Cursor { get; set; } |
The stack the player carries on the cursor while a container or his inventory screen is open. |
ItemStack Helmet { get; set; } |
The helmet. |
ItemStack Leggings { get; set; } |
The leggings. |
ItemStack MainHand { get; set; } |
The stack in the main hand (the selected hotbar slot). |
ItemStack OffHand { get; set; } |
The stack in the off hand. |
Player Player { get; } |
The player. |
int SelectedSlot { get; set; } |
The selected hotbar slot (0-8); setting it tells the client. |
override int Size { get; } |
public ItemStack Boots { get; set; }The boots.
Chestplate
Section titled “Chestplate”public ItemStack Chestplate { get; set; }The chestplate.
Cursor
Section titled “Cursor”public ItemStack Cursor { get; set; }The stack the player carries on the cursor while a container or his inventory screen is open. Setting it resyncs the client.
Helmet
Section titled “Helmet”public ItemStack Helmet { get; set; }The helmet.
Leggings
Section titled “Leggings”public ItemStack Leggings { get; set; }The leggings.
MainHand
Section titled “MainHand”public ItemStack MainHand { get; set; }The stack in the main hand (the selected hotbar slot).
OffHand
Section titled “OffHand”public ItemStack OffHand { get; set; }The stack in the off hand.
Player
Section titled “Player”public Player Player { get; }The player.
SelectedSlot
Section titled “SelectedSlot”public int SelectedSlot { get; set; }The selected hotbar slot (0-8); setting it tells the client.
public override int Size { get; }Methods
Section titled “Methods”| Member | Description |
|---|---|
int Give(ItemStack stack) |
Gives a stack to the player: what does not fit into the inventory is dropped at his feet (like picking up with a full inventory). |
ItemStack Hotbar(int index) |
The stack in a hotbar slot. |
static PlayerInventory Of(Player player) |
The inventory of a player. |
public int Give(ItemStack stack)Gives a stack to the player: what does not fit into the inventory is dropped at his feet (like picking up with a full inventory).
Parameters
| Name | Type | Description |
|---|---|---|
stack |
ItemStack |
The stack (any size: it is split). |
Returns int: How many items were dropped because they did not fit.
Hotbar
Section titled “Hotbar”public ItemStack Hotbar(int index)The stack in a hotbar slot.
Parameters
| Name | Type | Description |
|---|---|---|
index |
int |
0 to 8. |
Returns ItemStack: The stack.
public static PlayerInventory Of(Player player)The inventory of a player.
Parameters
| Name | Type | Description |
|---|---|---|
player |
Player |
The player. |
Returns PlayerInventory: The inventory.