Skip to content

Class endstone::ItemStack

ClassList > endstone > ItemStack

Represents a stack of items.

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

Public Functions

Type Name
ItemStack (const std::string & type, const int amount=1)
ItemStack (const ItemType & type, const int amount=1)
ItemStack (const ItemStack & stack)
virtual std::unique_ptr< ItemStack > clone () const
virtual int getAmount () const
Gets the amount of items in this stack.
virtual std::unique_ptr< ItemMeta > getItemMeta () const
Gets a copy of this ItemStack 'sItemMeta .
virtual int getMaxStackSize () const
Get the maximum stack size for this item.
virtual const ItemType & getType () const
Gets the type of this item.
virtual bool hasItemMeta () const
Checks to see if any metadata has been defined.
virtual bool isSimilar (const ItemStack & other) const
Checks if the two stacks are equal, but does not consider stack size (amount).
bool operator!= (const ItemStack & other) const
bool operator== (const ItemStack & other) const
virtual void setAmount (const int amount)
Sets the amount of items in this stack.
virtual bool setItemMeta (ItemMeta * meta)
Set the ItemMeta of thisItemStack .
virtual Result< void > setType (const std::string & type)
Sets the type of this item.
virtual void setType (const ItemType & type)
Sets the type of this item.
virtual ~ItemStack () = default

Public Static Functions

Type Name
Result< ItemStack > create (const ItemType & type, const int amount=1)
Result< ItemStack > create (const std::string & type, const int amount=1)

Protected Functions

Type Name
virtual bool isEndstoneItemStack () const

Public Functions Documentation

function ItemStack [⅓]

inline explicit endstone::ItemStack::ItemStack (
    const std::string & type,
    const int amount=1
) 

function ItemStack [⅔]

inline explicit endstone::ItemStack::ItemStack (
    const ItemType & type,
    const int amount=1
) 

function ItemStack [3/3]

inline endstone::ItemStack::ItemStack (
    const ItemStack & stack
) 

function clone

inline virtual std::unique_ptr< ItemStack > endstone::ItemStack::clone () const

function getAmount

Gets the amount of items in this stack.

inline virtual int endstone::ItemStack::getAmount () const

Returns:

Amount of items in this stack


function getItemMeta

Gets a copy of this ItemStack 'sItemMeta .

inline virtual std::unique_ptr< ItemMeta > endstone::ItemStack::getItemMeta () const

Returns:

a copy of the current ItemStack's ItemMeta


function getMaxStackSize

Get the maximum stack size for this item.

inline virtual int endstone::ItemStack::getMaxStackSize () const

Returns:

The maximum you can stack this item to.


function getType

Gets the type of this item.

inline virtual const ItemType & endstone::ItemStack::getType () const

Returns:

Type of the items in this stack


function hasItemMeta

Checks to see if any metadata has been defined.

inline virtual bool endstone::ItemStack::hasItemMeta () const

Returns:

Returns true if some metadata has been set for this item


function isSimilar

Checks if the two stacks are equal, but does not consider stack size (amount).

inline virtual bool endstone::ItemStack::isSimilar (
    const ItemStack & other
) const

Parameters:

  • other the item stack to compare to

Returns:

true if the two stacks are equal, ignoring the amount


function operator!=

inline bool endstone::ItemStack::operator!= (
    const ItemStack & other
) const

function operator==

inline bool endstone::ItemStack::operator== (
    const ItemStack & other
) const

function setAmount

Sets the amount of items in this stack.

inline virtual void endstone::ItemStack::setAmount (
    const int amount
) 

Parameters:

  • amount New amount of items in this stack

function setItemMeta

Set the ItemMeta of thisItemStack .

inline virtual bool endstone::ItemStack::setItemMeta (
    ItemMeta * meta
) 

Parameters:

  • meta new ItemMeta, or null to indicate meta data be cleared.

Returns:

True if successfully applied ItemMeta


function setType [½]

Sets the type of this item.

inline virtual Result< void > endstone::ItemStack::setType (
    const std::string & type
) 

Parameters:

  • type New type to set the items in this stack to

function setType [2/2]

Sets the type of this item.

inline virtual void endstone::ItemStack::setType (
    const ItemType & type
) 

Parameters:

  • type New type to set the items in this stack to

function ~ItemStack

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

Public Static Functions Documentation

function create [½]

static inline Result< ItemStack > endstone::ItemStack::create (
    const ItemType & type,
    const int amount=1
) 

function create [2/2]

static inline Result< ItemStack > endstone::ItemStack::create (
    const std::string & type,
    const int amount=1
) 

Protected Functions Documentation

function isEndstoneItemStack

inline virtual bool endstone::ItemStack::isEndstoneItemStack () const

Friends Documentation

friend EndstoneItemStack

class endstone::ItemStack::EndstoneItemStack (
    core::EndstoneItemStack
) 


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