Skip to content

PlayerInventory

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

public sealed class PlayerInventory : EngineInventory

The 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.

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.
public const int BootsSlot = 36;

The boots slot.

public const int ChestplateSlot = 38;

The chestplate slot.

public const int FirstMainSlot = 9;

First slot of the main inventory (below the hotbar).

public const int HelmetSlot = 39;

The helmet slot.

public const int LeggingsSlot = 37;

The leggings slot.

public const int OffHandSlot = 40;

The off hand slot.

public const int SlotCount = 41;

Number of slots.

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.

public ItemStack Chestplate { get; set; }

The chestplate.

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.

public ItemStack Helmet { get; set; }

The helmet.

public ItemStack Leggings { get; set; }

The leggings.

public ItemStack MainHand { get; set; }

The stack in the main hand (the selected hotbar slot).

public ItemStack OffHand { get; set; }

The stack in the off hand.

public Player Player { get; }

The player.

public int SelectedSlot { get; set; }

The selected hotbar slot (0-8); setting it tells the client.

public override int Size { get; }
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.

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.

EngineInventory · ItemStack · Player