Skip to main content

ItemStack

A proxy for an item stack from Minecraft

warning

This page is a WIP. It contains all the information in Figura's documentation but we're working on adding more helpful descriptions.

For all exmaples on this page assume:

local item = player:getHeldItem()

General​

getCount()​

Gets the number of items in this stack

getCount()

Returns:

TypeDescription
Integer-

Example:

item:getCount()

getID()​

Gets the ID of this stack

getID()

Returns:

TypeDescription
String-

Example:

item:getID()

getMaxCount()​

Gets the maximum stack size of this item

getMaxCount()

Returns:

TypeDescription
Integer-

Example:

item:getMaxCount()

getName()​

Gets the name of the item

getName()

Returns:

TypeDescription
String-

Example:

item:getName()

getPopTime()​

Gets the item's animation bobbing time, in ticks. This value is used to move an item to the player when it is picked up

getPopTime()

Returns:

TypeDescription
Integer-

Example:

item:getPopTime()

getRarity()​

Gets the rarity of this item stack

COMMON = white, UNCOMMON = yellow, RARE = aqua, EPIC = light purple

getRarity()

Returns:

TypeDescription
String-

Example:

item:getRarity()

getTag()​

Gets a table of the NBT tags of this stack

getTag()

Returns:

TypeDescription
Table-

Example:

item:getTag()

getTags()​

Gets all the tags of this item as strings in a table

getTags()

Returns:

TypeDescription
Table-

Example:

item:getTags()

getUseAction()​

Returns the name of the animation that plays when using this item

getUseAction()

Returns:

TypeDescription
String-

Example:

item:getUseAction()

getUseDuration()​

Gets the number of ticks needed to "use" this item

Currently only has a use for food items

Always 32 for food items except kelp, which is 16

getUseDuration()

Returns:

TypeDescription
Integer-

Example:

item:getUseDuration()

copy()​

Returns a copy of this item stack

copy()

Returns:

TypeDescription
ItemStackReturns self for chaining

Example:

item:copy()

hasGlint()​

Returns true if this item glows with enchantment glint

hasGlint()

Returns:

TypeDescription
Boolean-

Example:

item:hasGlint()

isFood()​

Returns true if this item is edible

isFood()

Returns:

TypeDescription
Boolean-

Example:

item:isFood()

isStackable()​

Returns true if the item is stackable

isStackable()

Returns:

TypeDescription
Boolean-

Example:

item:isStackable()

toStackString()​

Converts this ItemStack to a string, as you'd see in a command

toStackString()

Returns:

TypeDescription
String-

Example:

item:toStackString()

Equipment/Tools​

getDamage()​

Gets the damage value of the item in this stack

Works on things like tools, or other things with a durability bar

getDamage()

Returns:

TypeDescription
Integer-

Example:

item:getDamage()

getEquipmentSlot()​

Returns the slot name of where this item is used

getEquipmentSlot()

Returns:

TypeDescription
String-

Example:

item:getEquipmentSlot()

getMaxDamage()​

Gets the maximum durability of this item stack

getMaxDamage()

Returns:

TypeDescription
Integer-

Example:

item:getMaxDamage()

getRepairCost()​

Gets the repair cost modifier, in an anvil, for this item stack

getRepairCost()

Returns:

TypeDescription
Integer-

Example:

item:getRepairCost()

isArmor()​

Checks if this item is Armor

isArmor()

Returns:

TypeDescription
Boolean-

Example:

item:isArmor()

isDamageable()​

Returns true if this item stack has durability

isDamageable()

Returns:

TypeDescription
Boolean-

Example:

item:isDamageable()

isEnchantable()​

Returns true if this item stack can be put in an enchanting table

isEnchantable()

Returns:

TypeDescription
Boolean-

Example:

item:isEnchantable()

isTool()​

Check if this item is a Tool (Axe, Shovel, Pickaxe, …)

isTool()

Returns:

TypeDescription
Boolean-

Example:

item:isTool()

Block Items​

getBlockstate()​

Returns the blockstate representation of this item stack

If this item has no block representation, returns nil

getBlockstate()

Returns:

TypeDescription
BlockState-

Example:

item:getBlockstate()

isBlockItem()​

Returns true if this item represents a block

isBlockItem()

Returns:

TypeDescription
Boolean-

Example:

item:isBlockItem()

Fields​

id​

Contains the id of the item this ItemStack refers to

Example:

item.id

tag​

A table containing the NBT tag of this ItemStack

If this ItemStack has nothing in its tag, it is nil

Example:

item.tag