Skip to Content
⚠ Under Construction
ReferenceC++ APIPlayerInventory

endstone::PlayerInventory

Interface to the inventory of a Player , including the four armor slots and any extra slots.

Bases: endstone::Inventory

Functions:

NameDescription
getBootsReturn the ItemStack from the boots slot.
getChestplateReturn the ItemStack from the chestplate slot.
getHeldItemSlotGet the slot number of the currently held item.
getHelmetReturn the ItemStack from the helmet slot.
getItemInMainHandGets the item the player is currently holding in their main hand.
getItemInOffHandGets the item the player is currently holding in their off hand.
getLeggingsReturn the ItemStack from the leg slot.
setBootsPut the given ItemStack into the boots slot.
setChestplatePut the given ItemStack into the chestplate slot.
setHeldItemSlotSet the slot number of the currently held item.
setHelmetPut the given ItemStack into the helmet slot.
setItemInMainHandSets the item the player is holding in their main hand.
setItemInOffHandSets the item the player is holding in their off hand.
setLeggingsPut the given ItemStack into the leggings slot.

getBoots

std::unique_ptr<ItemStack> getBoots() const

Return the ItemStack from the boots slot.

Returns:

The ItemStack in the boots slot

getChestplate

std::unique_ptr<ItemStack> getChestplate() const

Return the ItemStack from the chestplate slot.

Returns:

The ItemStack in the chestplate slot

getHeldItemSlot

int getHeldItemSlot() const

Get the slot number of the currently held item.

Returns:

Held item slot number

getHelmet

std::unique_ptr<ItemStack> getHelmet() const

Return the ItemStack from the helmet slot.

Returns:

The ItemStack in the helmet slot

getItemInMainHand

std::unique_ptr<ItemStack> getItemInMainHand() const

Gets the item the player is currently holding in their main hand.

Returns:

the currently held item

getItemInOffHand

std::unique_ptr<ItemStack> getItemInOffHand() const

Gets the item the player is currently holding in their off hand.

Returns:

the currently held item

getLeggings

std::unique_ptr<ItemStack> getLeggings() const

Return the ItemStack from the leg slot.

Returns:

The ItemStack in the leg slot

setBoots

void setBoots(const ItemStack *boots)

Put the given ItemStack into the boots slot.

This does not check if the ItemStack is a pair of boots.

Parameters:

setChestplate

void setChestplate(const ItemStack *chestplate)

Put the given ItemStack into the chestplate slot.

This does not check if the ItemStack is a chestplate.

Parameters:

  • chestplate The ItemStack to use as chestplate

setHeldItemSlot

Result<void> setHeldItemSlot(int slot)

Set the slot number of the currently held item.

This validates whether the slot is between 0 and 8 inclusive.

Parameters:

  • slot The new slot number

setHelmet

void setHelmet(const ItemStack *helmet)

Put the given ItemStack into the helmet slot.

This does not check if the ItemStack is a helmet.

Parameters:

setItemInMainHand

void setItemInMainHand(const ItemStack *item)

Sets the item the player is holding in their main hand.

Parameters:

  • item The item to put into the player’s hand

setItemInOffHand

void setItemInOffHand(const ItemStack *item)

Sets the item the player is holding in their off hand.

Parameters:

  • item The item to put into the player’s hand

setLeggings

void setLeggings(const ItemStack *leggings)

Put the given ItemStack into the leggings slot.

This does not check if the ItemStack is a pair of leggings.

Parameters:

Last updated on