Skip to content

ItemStack

Metatable name: "item"

type: string

Item identifier (e.g. "minecraft:diamond"). Read-only.

type: number

Stack size.

type: string or nil

Custom name. Assign or nil to remove.

type: table

Lore lines as an array of strings. Assign or nil to remove.

local item = mc.createItem("diamond")
item.lore = {
"Cool diamond",
"Very cool diamond"
}

type: boolean

type: number or nil

Custom model data integer.

Returns an independent copy of the item stack.

Creates an item stack with the given count.

  • id (string) — Item identifier
  • count (number) — Stack size
local diamonds = mc.createItem("diamond", 16)

Creates an item stack with full component data.

  • id (string) — Item identifier

components table:

ComponentTypeDescription
countnumberStack size
namestringCustom name (& color codes)
loretableArray of lore lines
custom_model_datanumberCustom model data
unbreakablebooleanUnbreakable flag
Additional component keys may work depending on the item type (e.g., potion_effects, firework, block_state).
Keys that don’t exist on the given item type are silently ignored.
local sword = mc.createItem("diamond_sword", {
count = 1,
name = "&bLegendary Blade",
lore = { "&7A mighty weapon", "", "&6+10 Attack Damage" },
custom_model_data = 500,
unbreakable = true
})

Use item:copy() to work with an independent copy.

local item = player.mainhand
item.count = 99 -- the amount changes real-time
local item2 = item:copy() -- A copy
player:setItem(player.selectedSlot, item2) -- Safe
player:setItem(player.selectedSlot, item) -- Safe too (implicit copy)
player.offhand = item -- And this is safe too, yeah