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 (ItemId type, const int amount=1, const int data=0)
ItemStack (const ItemStack & stack)
virtual std::unique_ptr< ItemStack > clone () const
virtual int getAmount () const
Gets the amount of items in this stack.
virtual int getData () const
Gets the data for this stack of items.
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 std::string getTranslationKey () const
Get the translation key, suitable for use in a translation component.
virtual ItemId 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 Result< void > setAmount (const int amount)
Sets the amount of items in this stack.
virtual void setData (const int data)
Sets the data for this stack of items.
virtual bool setItemMeta (ItemMeta * meta)
Set the ItemMeta of thisItemStack .
virtual Result< void > setType (ItemId type)
Sets the type of this item.
virtual CompoundTag toNbt () const
Serializes this ItemStack into a Named Binary Tag (NBT)
virtual ~ItemStack () = default

Public Static Functions

Type Name
std::unique_ptr< ItemStack > fromNbt (const CompoundTag & tag)
Deserializes an ItemStack from a Named Binary Tag (NBT).

Protected Functions

Type Name
virtual bool isEndstoneItemStack () const

Public Functions Documentation

function ItemStack [⅔]

inline explicit endstone::ItemStack::ItemStack (
    ItemId type,
    const  int amount=1,
    const  int data=0
) 

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 getData

Gets the data for this stack of items.

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

Returns:

Data for this item


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 getTranslationKey

Get the translation key, suitable for use in a translation component.

inline virtual std::string endstone::ItemStack::getTranslationKey () const

Returns:

the translation key


function getType

Gets the type of this item.

inline virtual ItemId 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 Result< void > endstone::ItemStack::setAmount (
    const  int amount
) 

Parameters:

  • amount New amount of items in this stack

function setData

Sets the data for this stack of items.

inline virtual void endstone::ItemStack::setData (
    const  int data
) 

Parameters:

  • data New data for this item

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 (
    ItemId type
) 

Parameters:

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

function toNbt

Serializes this ItemStack into a Named Binary Tag (NBT)

inline virtual CompoundTag endstone::ItemStack::toNbt () const

Returns:

A CompoundTag containing the NBT of this ItemStack.


function ~ItemStack

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

Public Static Functions Documentation

function fromNbt

Deserializes an ItemStack from a Named Binary Tag (NBT).

static inline std::unique_ptr< ItemStack > endstone::ItemStack::fromNbt (
    const  CompoundTag & tag
) 

Parameters:

Returns:

The ItemStack created from the provided NBT.


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