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 (ItemTypeId type, int amount=1, int data=0)
An item stack.
ItemStack (const ItemStack & other)
ItemStack (ItemStack && other) noexcept
int getAmount () const
Gets the amount of items in this stack.
int getData () const
Gets the data for this stack of items.
std::unique_ptr< ItemMeta > getItemMeta () const
Gets a copy of this ItemStack 'sItemMeta .
int getMaxStackSize () const
Get the maximum stack size for this item.
CompoundTag getNbt () const
Gets the NBT compound tag of this item stack.
std::string getTranslationKey () const
Get the translation key, suitable for use in a translation component.
const ItemType & getType () const
Gets the type of this item.
bool hasItemMeta () const
Checks to see if any metadata has been defined.
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
ItemStack & operator= (const ItemStack & other)
ItemStack & operator= (ItemStack && other) noexcept
bool operator== (const ItemStack & other) const
void setAmount (int amount)
Sets the amount of items in this stack.
void setData (int data)
Sets the data for this stack of items.
bool setItemMeta (ItemMeta * meta)
Set the ItemMeta of thisItemStack .
void setNbt (const CompoundTag & nbt)
Sets the NBT compound tag of this item stack.
void setType (ItemTypeId type)
Sets the type of this item.
~ItemStack () = default

Public Functions Documentation

function ItemStack [¼]

An item stack.

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

Parameters:

  • type the type
  • amount the amount in the stack
  • data the data value

function ItemStack [2/4]

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

function ItemStack [¾]

endstone::ItemStack::ItemStack (
    ItemStack && other
) noexcept

function getAmount

Gets the amount of items in this stack.

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

Returns:

Amount of items in this stack


function getData

Gets the data for this stack of items.

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

Returns:

Data for this item


function getItemMeta

Gets a copy of this ItemStack 'sItemMeta .

inline 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 int endstone::ItemStack::getMaxStackSize () const

Returns:

The maximum you can stack this item to.


function getNbt

Gets the NBT compound tag of this item stack.

inline CompoundTag endstone::ItemStack::getNbt () const

Returns:

the NBT compound tag


function getTranslationKey

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

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

Returns:

the translation key


function getType

Gets the type of this item.

inline 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 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 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 ItemStack & endstone::ItemStack::operator= (
    const  ItemStack & other
) 

function operator=

ItemStack & endstone::ItemStack::operator= (
    ItemStack && other
) noexcept

function operator==

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

function setAmount

Sets the amount of items in this stack.

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

Parameters:

  • amount New amount of items in this stack

function setData

Sets the data for this stack of items.

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

Parameters:

  • data New data for this item

function setItemMeta

Set the ItemMeta of thisItemStack .

inline 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 setNbt

Sets the NBT compound tag of this item stack.

inline void endstone::ItemStack::setNbt (
    const  CompoundTag & nbt
) 

Parameters:

  • nbt the NBT compound tag to set

function setType

Sets the type of this item.

inline void endstone::ItemStack::setType (
    ItemTypeId type
) 

Parameters:

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

function ~ItemStack

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

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