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 Result< 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 std::unordered_map< int, ItemStack * > addItem (std::vector< ItemStack * > items) = 0
Stores the given ItemStacks in the inventory.
std::unordered_map< int, ItemStack * > addItem (Args &&... items)
Stores the given ItemStacks in the inventory.
virtual Result< std::unordered_map< int, std::unique_ptr< ItemStack > > > all (const std::string & type) const = 0
Finds all slots in the inventory containing any ItemStacks with the given ItemType .
virtual std::unordered_map< int, std::unique_ptr< ItemStack > > all (const ItemStack & item) const = 0
Finds all slots in the inventory containing any ItemStacks with the given ItemStack .
virtual void clear (int index) = 0
Clears out a particular slot in the index.
virtual void clear () = 0
Clears out the whole Inventory .
virtual Result< bool > contains (const std::string & type) const = 0
Checks if the inventory contains any ItemStacks with the given ItemType .
virtual bool contains (const ItemStack & item) const = 0
Checks if the inventory contains any ItemStacks with the given ItemStack .
virtual bool contains (const ItemStack & item, int amount) const = 0
Checks if the inventory contains at least the minimum amount specified of exactly matching ItemStacks.
virtual Result< bool > containsAtLeast (const std::string & type, int amount) const = 0
Checks if the inventory contains any ItemStacks with the given ItemType , adding to at least the minimum amount specified.
virtual bool containsAtLeast (const ItemStack & item, int amount) const = 0
Checks if the inventory contains ItemStacks matching the given ItemStack whose amounts sum to at least the minimum amount specified.
virtual Result< int > first (const std::string & type) const = 0
Finds the first slot in the inventory containing an ItemStack with the givenItemType .
virtual int first (const ItemStack & item) const = 0
Returns the first slot in the inventory containing an ItemStack with the given stack.
virtual int firstEmpty () const = 0
Returns the first empty Slot.
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 Result< void > remove (const std::string & type) = 0
Removes all stacks in the inventory matching the given ItemType .
virtual void remove (const ItemStack & item) = 0
Removes all stacks in the inventory matching the given stack.
virtual std::unordered_map< int, ItemStack * > removeItem (std::vector< ItemStack * > items) = 0
Removes the given ItemStacks from the inventory.
std::unordered_map< int, ItemStack * > removeItem (Args &&... items)
Removes the given ItemStacks from the inventory.
virtual Result< void > setContents (std::vector< const ItemStack * > items) = 0
Completely replaces the inventory's contents. Removes all existing contents and replaces it with the ItemStacks given in the array.
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 Result< 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