Skip to Content
⚠ Under Construction
ReferenceC++ APIItemStack

endstone::ItemStack

Represents a stack of items.

Functions:

NameDescription
ItemStack
ItemStack
clone
getAmountGets the amount of items in this stack.
getDataGets the data for this stack of items.
getItemMetaGets a copy of this ItemStack ‘s ItemMeta .
getMaxStackSizeGet the maximum stack size for this item.
getTypeGets the type of this item.
hasItemMetaChecks to see if any metadata has been defined.
isSimilarChecks if the two stacks are equal, but does not consider stack size (amount).
setAmountSets the amount of items in this stack.
setDataSets the data for this stack of items.
setItemMetaSet the ItemMeta of this ItemStack .
setTypeSets the type of this item.

ItemStack

ItemStack(const std::string &type = "minecraft:air", const int amount = 1, const int data = 0)
ItemStack(const ItemStack &stack)

clone

std::unique_ptr<ItemStack> clone() const

getAmount

int getAmount() const

Gets the amount of items in this stack.

Returns:

Amount of items in this stack

getData

int getData() const

Gets the data for this stack of items.

Returns:

Data for this item

getItemMeta

std::unique_ptr<ItemMeta> getItemMeta() const

Gets a copy of this ItemStack ‘s ItemMeta .

Returns:

a copy of the current ItemStack’s ItemMeta

getMaxStackSize

int getMaxStackSize() const

Get the maximum stack size for this item.

Returns:

The maximum you can stack this item to.

getType

std::string getType() const

Gets the type of this item.

Returns:

Type of the items in this stack

hasItemMeta

bool hasItemMeta() const

Checks to see if any metadata has been defined.

Returns:

Returns true if some metadata has been set for this item

isSimilar

bool isSimilar(const ItemStack &other) const

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

Parameters:

  • other the item stack to compare to

Returns:

true if the two stacks are equal, ignoring the amount

setAmount

void setAmount(const int amount)

Sets the amount of items in this stack.

Parameters:

  • amount New amount of items in this stack

setData

void setData(const int data)

Sets the data for this stack of items.

Parameters:

  • data New data for this item

setItemMeta

bool setItemMeta(ItemMeta *meta)

Set the ItemMeta of this ItemStack .

Parameters:

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

Returns:

True if successfully applied ItemMeta

setType

void setType(const std::string &type)

Sets the type of this item.

Parameters:

  • type New type to set the items in this stack to
Last updated on