Skip to content

Item handle

Live handle to one item stack. From e:held_item(), e:equipped(slot), inventory.item, game.item(id), and similar. An inventory slot handle tracks whatever is in that slot now.

Methods

Method Meaning
id, name, count Item id ("minecraft:diamond_sword"), display name, stack size
empty true for an empty slot
max_count, stackable Max stack size
rarity "common", "uncommon", "rare", "epic"
use_action "none", "eat", "drink", "block", "bow", "spear", …
damage, max_damage Durability used / maximum (0 if not damageable)
damageable, damaged, unbreakable Durability flags
enchanted true if any enchantment
enchantments id -> level, e.g. item:enchantments()["minecraft:sharpness"] == 5
custom_name Anvil name, or nil
name_text, display_name Display name as text snapshots
item_name, formatted_name Base name / rarity-formatted name as text
custom_name_text Anvil name as text, or nil
hover_text Bracketed chat name ([Diamond Sword] with show-item hover)
lore Lore lines as text components, or nil
tooltip(advanced?) Tooltip lines exactly as the inventory renders them
food {nutrition, saturation, can_always_eat} for food, or nil
tags Item tag ids, e.g. "minecraft:swords"
attribute_modifiers {attribute, id, value, operation, slot}[], or nil

Data components

Method What it does
item:has_component(id) true if the stack has the component
item:component(id) Decoded Lua value; true if present but not decodable; nil if absent
local held = player:held_item()
if held:enchantments()["minecraft:sharpness"] then
    print(held:name() .. " has Sharpness")
end
if held:has_component("minecraft:piercing_weapon") then
    local weapon = held:component("minecraft:piercing_weapon")
    print(held:name() .. " dismounts: " .. tostring(weapon.dismounts))
end
Navigation

Type to search…

↑↓ navigate↵ selectEsc close