Skip to content

ItemStack

The ItemStack wrapper provides read-only access to Minecraft item stacks. All wrappers returned to Lua are copies — raw references never leak from the Lua boundary.

Metatable name: "item"

type: string

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

type: number

Stack size. Read-only.

type: number or nil

Custom model data integer. Read-only.

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
attackDamagenumberAttack damage

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,
attackDamage = 10
})

All wrappers returned to Lua are copies. This means:

  • Lua scripts can never mutate the server’s internal item stacks
  • Modifications must go through API methods (player:setItem(), inv:setItem())
  • Multiple reads of the same slot return independent copies
local item = player.mainhand
item.count = 99 -- no effect, properties are read-only
player:setItem(player.selectedSlot, mc.createItem("diamond", 99))