ItemStack API

Item

An Item represents a Minecraft item stack with material, amount, name, lore, and NBT data.


Constructor

Item(material=None, amount=1, name=None, lore=None, custom_model_data=None, attributes=None, nbt=None)

Create an item.

sword = Item("DIAMOND_SWORD", name="§bFrostbrand", lore=["§7A blade of ice"])
blocks = Item(Material.STONE, amount=64)

Class Methods

drop

entity = await Item.drop(material, location, amount=1, **kwargs)

Drop an item entity at a location.

await Item.drop("DIAMOND", player.location, amount=5)

give

await Item.give(player, material, amount=1, **kwargs)

Give an item directly to a player's inventory.

await Item.give(player, "GOLDEN_APPLE", 3)

Attributes

type

The item's material type.

amount

Current stack size.

name

Display name, or None for the default name.

lore

Lore lines displayed below the item name.

custom_model_data

Custom model data value for resource packs.

attributes

Attribute modifiers (attack damage, armor, etc.).

nbt

The item's NBT data as a dictionary.

max_stack_size

Maximum stack size for this item type (e.g. 64 for blocks, 16 for ender pearls, 1 for tools).

durability

Current durability of the item.

max_durability

Maximum durability for this item type. Read-only.

enchantments

All enchantments on the item as a {{name: level}} dictionary. Read-only.

item_flags

Item flags (e.g. HIDE_ENCHANTS, HIDE_ATTRIBUTES).

is_unbreakable

Whether the item is unbreakable.


Methods

set_amount

await item.set_amount(value)

Set the stack size. Property syntax: item.amount = 32.

set_name

await item.set_name(name)

Set the display name.

set_lore

await item.set_lore(lore)

Set the lore lines.

set_custom_model_data

await item.set_custom_model_data(value)

Set custom model data. Property syntax: item.custom_model_data = 100.

set_attributes

await item.set_attributes(attributes)

Set attribute modifiers. Property syntax: item.attributes = [...].

set_nbt

await item.set_nbt(nbt)

Set raw NBT data. Property syntax: item.nbt = {{...}}.

clone

copy = await item.clone()

Create a deep copy of this item.

is_similar

result = await item.is_similar(other)

Check if two items are similar (same type, name, lore — ignoring amount).


Enchantments

add_enchantment

await item.add_enchantment(enchantment, level=1)

Add an enchantment to the item.

remove_enchantment

await item.remove_enchantment(enchantment)

Remove an enchantment from the item.

await sword.add_enchantment("SHARPNESS", 5)
await sword.add_enchantment("FIRE_ASPECT", 2)
print(sword.enchantments)  # {{"SHARPNESS": 5, "FIRE_ASPECT": 2}}
await sword.remove_enchantment("FIRE_ASPECT")

Item Flags

add_item_flags

await item.add_item_flags(*flags)

Add item flags.

remove_item_flags

await item.remove_item_flags(*flags)

Remove item flags.