Skip to content

Item

Represents an in-game item, including information about its type, name, quantity, durability, and metadata.

Fields

count: number Read/Write

The quantity of the item in a stack.

damage: number Read/Write

The current damage value, representing how worn or used the item is.

maxCount: number Read-Only

The maximum quantity of the item in a stack.

maxDamage: number Read-Only

The maximum durability value this item can have before breaking.

name: string Read/Write

The name of the item, typically a human-readable label.

nbt: table Read/Write

A copy of the NBT (Named Binary Tag) data attached to the item, including custom components and metadata. Changes made to this table do not affect the actual item until reassigned.

To modify the NBT effectively, use one of the following methods:

  1. Retrieve a copy, modify it, then reassign:

    local copy = item.nbt
    copy.count = copy.count + 1
    item.nbt = copy
    

  2. Use putNbt(...) to merge changes:

    item:putNbt({ count = 20 })
    

stackable: boolean Read-Only

Indicates whether the item can be stacked.

type: ItemType Read-Only

A reference to the specific type of the item (e.g., "sword", "pickaxe").

Methods

new(id: string, nbt?: table) item: Item

Creates a new item with the specified ID and optional NBT data.

Example

local item = Item:new("diamond_sword", {
  components = {
    custom_name = {
      text = "Radiant Diamond Sword",
      color = "aqua",
      bold = true,
      italic = false
    },
    lore = {
      { text = "A diamond sword shimmering with energy", color = "gold", bold = true }
    }
  }
})

Parameters

  • id: string The item type identifier (e.g., "diamond_sword", "torch").
  • nbt?: table NBT data for customizing the item’s appearance or behavior.

Returns

  • item: Item A new item instance with the specified type and optional NBT data.

copy() item: Item

Creates a copy of this item.

Example

local item = spell.owner.mainHandItem:copy()
spell.owner.inventory[40] = item

Returns

  • item: Item A new copy of this item.

putNbt(nbt: table)

Merges the given NBT data into this item's existing NBT.

This updates properties like the custom name, enchantments, or other item components.

Example

item:putNbt({
  components = {
    enchantments = {
      sharpness = 5,
      unbreaking = 3
    }
  }
})

Parameters

  • nbt: table The NBT data to merge into this item.