ItemStack
A proxy for an item stack from Minecraft
For all exmaples on this page assume:
local item = player:getHeldItem()
getName()
Gets the name of the item
Example:
item:getName()
copy()
Returns a copy of this item stack
Example:
item:copy()
getCount()
Gets the number of items in this stack
Example:
item:getCount()
getTag()
Gets a table of the NBT tags of this stack
Example:
item:getTag()
getTags()
Gets all the tags of this item as strings in a table
Example:
item:getTags()
getID()
Gets the ID of this stack
Example:
item:getID()
getDamage()
Gets the damage value of the item in this stack
Works on things like tools, or other things with a durability bar
Example:
item:getDamage()
isEnchantable()
Returns true if this item stack can be put in an enchanting table
Example:
item:isEnchantable()
hasGlint()
Returns true if this item glows with enchantment glint
Example:
item:hasGlint()
getMaxCount()
Gets the maximum stack size of this item
Example:
item:getMaxCount()
getMaxDamage()
Gets the maximum durability of this item stack
Example:
item:getMaxDamage()
isDamageable()
Returns true if this item stack has durability
Example:
item:isDamageable()
isStackable()
Returns true if the item is stackable
Example:
item:isStackable()
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
Example:
item:getUseDuration()
isFood()
Returns true if this item is edible
Example:
item:isFood()
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
Example:
item:getPopTime()
getRepairCost()
Gets the repair cost modifier, in an anvil, for this item stack
Example:
item:getRepairCost()
toStackString()
Converts this ItemStack to a string, like you'd see in a command
Example:
item:toStackString()
getRarity()
Gets the rarity of this item stack
COMMON = white, UNCOMMON = yellow, RARE = aqua, EPIC = light purple
Example:
item:getRarity()
getUseAction()
Returns the name of the animation that plays when using this item
Example:
item:getUseAction()
isTool()
Check if this item is a Tool (Axe, Shovel, Pickaxe, ...)
Example:
item:isTool()
isBlockItem()
Returns true if this item represents a block
Example:
item:isBlockItem()
getBlockstate()
Returns the blockstate representation of this item stack
If this item has no block representation, returns nil
Example:
item:getBlockstate()
getEquipmentSlot()
Returns the slot name of where this item is used
Example:
item:getEquipmentSlot()
isArmor()
Checks if this item is a Armor
Example:
item:isArmor()
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