Skip to content

inventory

Inventory actions scheduled to a safe point of the tick — works cleanly with movement and packets.

Function What it does
inventory.swap(a, b) Swaps two slots
inventory.drop(slot[, all]) Drops from a slot (all defaults to true — whole stack)
inventory.merge(from, to) Moves a stack onto another
inventory.use(slot[, yaw, pitch]) Uses the item in a slot, optionally facing a direction first
inventory.item(slot) Live item handle, or nil
inventory.find(item_id) First slot holding that item, or nil
inventory.count(item_id) Total count of that item you carry
inventory.cooldown(item_id) Cooldown progress [0, 1]1 just after use, down to 0 when ready
inventory.slot() Selected hotbar slot (0–8)
inventory.set_slot(i) Selects a hotbar slot (0–8)

Slot numbering

Range Meaning
0 Crafting result
1–4 Crafting grid
5–8 Armor (helmet → boots)
9–35 Main inventory
36–44 Hotbar
45 Offhand
module:event("tick", function()
    local totem = inventory.find("minecraft:totem_of_undying")
    if totem and inventory.item(45):id() ~= "minecraft:totem_of_undying" then
        inventory.swap(totem, 45)
    end
end)
Navigation

Type to search…

↑↓ navigate↵ selectEsc close