Skip to content

Class endstone::Inventory

ClassList > endstone > Inventory

Interface to the various inventories.

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

Inherited by the following classes: endstone::PlayerInventory

Public Functions

Type Name
virtual void addItem (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 (ItemStack & item) = 0
Returns the first slot in the inventory containing an ItemStack with the given stack.
virtual std::vector< std::shared_ptr< ItemStack > > getContents () const = 0
Returns all ItemStacks from the inventory.
virtual std::shared_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, std::shared_ptr< ItemStack > item) = 0
Stores the ItemStack at the given index of the inventory.
virtual ~Inventory () = default

Public Functions Documentation

function addItem

Stores the given ItemStacks in the inventory. This will try to fill existing stacks and empty slots as well as it can.

virtual void endstone::Inventory::addItem (
    ItemStack & item
) = 0

Parameters:


function clear

virtual void endstone::Inventory::clear () = 0

function first

Returns the first slot in the inventory containing an ItemStack with the given stack.

virtual int endstone::Inventory::first (
    ItemStack & item
) = 0

Parameters:

Returns:

The slot index of the given ItemStack or -1 if not found


function getContents

Returns all ItemStacks from the inventory.

virtual std::vector< std::shared_ptr< ItemStack > > endstone::Inventory::getContents () const = 0

Returns:

An array of ItemStacks from the inventory. Individual items may be null.


function getItem

Returns the ItemStack found in the slot at the given index.

virtual std::shared_ptr< ItemStack > endstone::Inventory::getItem (
    int index
) const = 0

Parameters:

  • index The index of the Slot's ItemStack to return

Returns:

The ItemStack in the slot


function getMaxStackSize

Returns the maximum stack size for an ItemStack in this inventory.

virtual int endstone::Inventory::getMaxStackSize () const = 0

Returns:

The maximum size for an ItemStack in this inventory.


function getSize

Returns the size of the inventory.

virtual int endstone::Inventory::getSize () const = 0

Returns:

The size of the inventory


function isEmpty

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 bool endstone::Inventory::isEmpty () const = 0

Returns:

true if empty, false otherwise


function setItem

Stores the ItemStack at the given index of the inventory.

virtual void endstone::Inventory::setItem (
    int index,
    std::shared_ptr< ItemStack > item
) = 0

Parameters:


function ~Inventory

virtual endstone::Inventory::~Inventory () = default


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