Skip to content

Class endstone::PlayerInventory

ClassList > endstone > PlayerInventory

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

  • #include <endstone/inventory/player_inventory.h>

Inherits the following classes: endstone::Inventory

Public Functions

Type Name
virtual std::unique_ptr< ItemStack > getBoots () const = 0
Return the ItemStack from the boots slot.
virtual std::unique_ptr< ItemStack > getChestplate () const = 0
Return the ItemStack from the chestplate slot.
virtual int getHeldItemSlot () const = 0
Get the slot number of the currently held item.
virtual std::unique_ptr< ItemStack > getHelmet () const = 0
Return the ItemStack from the helmet slot.
virtual std::unique_ptr< ItemStack > getItemInMainHand () const = 0
Gets the item the player is currently holding in their main hand.
virtual std::unique_ptr< ItemStack > getItemInOffHand () const = 0
Gets the item the player is currently holding in their off hand.
virtual std::unique_ptr< ItemStack > getLeggings () const = 0
Return the ItemStack from the leg slot.
virtual void setBoots (const ItemStack * boots) = 0
Put the given ItemStack into the boots slot.
virtual void setChestplate (const ItemStack * chestplate) = 0
Put the given ItemStack into the chestplate slot.
virtual void setHeldItemSlot (int slot) = 0
Set the slot number of the currently held item.
virtual void setHelmet (const ItemStack * helmet) = 0
Put the given ItemStack into the helmet slot.
virtual void setItemInMainHand (const ItemStack * item) = 0
Sets the item the player is holding in their main hand.
virtual void setItemInOffHand (const ItemStack * item) = 0
Sets the item the player is holding in their off hand.
virtual void setLeggings (const ItemStack * leggings) = 0
Put the given ItemStack into the leggings slot.

Public Functions inherited from endstone::Inventory

See endstone::Inventory

Type Name
virtual void addItem (const ItemStack & item) = 0
Stores the given ItemStacks in the inventory. This will try to fill existing stacks and empty slots as well as it can.
virtual void clear () = 0
Clears out the whole Inventory .
virtual int first (const ItemStack & item) const = 0
Returns the first slot in the inventory containing an ItemStack with the given stack.
virtual std::vector< std::unique_ptr< ItemStack > > getContents () const = 0
Returns all ItemStacks from the inventory.
virtual std::unique_ptr< ItemStack > getItem (int index) const = 0
Returns the ItemStack found in the slot at the given index.
virtual int getMaxStackSize () const = 0
Returns the maximum stack size for an ItemStack in this inventory.
virtual int getSize () const = 0
Returns the size of the inventory.
virtual bool isEmpty () const = 0
Check whether this inventory is empty. An inventory is considered to be empty if there are no ItemStacks in any slot of this inventory.
virtual void setItem (int index, const ItemStack * item) = 0
Stores the ItemStack at the given index of the inventory.
virtual ~Inventory () = default

Public Functions Documentation

function getBoots

Return the ItemStack from the boots slot.

virtual std::unique_ptr< ItemStack > endstone::PlayerInventory::getBoots () const = 0

Returns:

The ItemStack in the boots slot


function getChestplate

Return the ItemStack from the chestplate slot.

virtual std::unique_ptr< ItemStack > endstone::PlayerInventory::getChestplate () const = 0

Returns:

The ItemStack in the chestplate slot


function getHeldItemSlot

Get the slot number of the currently held item.

virtual int endstone::PlayerInventory::getHeldItemSlot () const = 0

Returns:

Held item slot number


function getHelmet

Return the ItemStack from the helmet slot.

virtual std::unique_ptr< ItemStack > endstone::PlayerInventory::getHelmet () const = 0

Returns:

The ItemStack in the helmet slot


function getItemInMainHand

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

virtual std::unique_ptr< ItemStack > endstone::PlayerInventory::getItemInMainHand () const = 0

Returns:

the currently held item


function getItemInOffHand

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

virtual std::unique_ptr< ItemStack > endstone::PlayerInventory::getItemInOffHand () const = 0

Returns:

the currently held item


function getLeggings

Return the ItemStack from the leg slot.

virtual std::unique_ptr< ItemStack > endstone::PlayerInventory::getLeggings () const = 0

Returns:

The ItemStack in the leg slot


function setBoots

Put the given ItemStack into the boots slot.

virtual void endstone::PlayerInventory::setBoots (
    const  ItemStack * boots
) = 0

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

Parameters:


function setChestplate

Put the given ItemStack into the chestplate slot.

virtual void endstone::PlayerInventory::setChestplate (
    const  ItemStack * chestplate
) = 0

This does not check if the ItemStack is a chestplate.

Parameters:

  • chestplate The ItemStack to use as chestplate

function setHeldItemSlot

Set the slot number of the currently held item.

virtual void endstone::PlayerInventory::setHeldItemSlot (
    int slot
) = 0

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

Parameters:

  • slot The new slot number

function setHelmet

Put the given ItemStack into the helmet slot.

virtual void endstone::PlayerInventory::setHelmet (
    const  ItemStack * helmet
) = 0

This does not check if the ItemStack is a helmet.

Parameters:


function setItemInMainHand

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

virtual void endstone::PlayerInventory::setItemInMainHand (
    const  ItemStack * item
) = 0

Parameters:

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

function setItemInOffHand

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

virtual void endstone::PlayerInventory::setItemInOffHand (
    const  ItemStack * item
) = 0

Parameters:

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

function setLeggings

Put the given ItemStack into the leggings slot.

virtual void endstone::PlayerInventory::setLeggings (
    const  ItemStack * leggings
) = 0

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

Parameters:



The documentation for this class was generated from the following file include/endstone/inventory/player_inventory.h