Fluent item construction

ItemBuilder

A fluent builder for constructing Item objects. Every setter method returns self, allowing chained calls.


Constructor

ItemBuilder(material)

Start building an item with the given material.

sword = (
    ItemBuilder("DIAMOND_SWORD")
    .name("§6Excalibur")
    .lore("§7Legendary blade", "§7of kings")
    .enchant("SHARPNESS", 5)
    .unbreakable()
    .glow()
    .build()
)

Class Methods

from_item

builder = ItemBuilder.from_item(item)

Create a builder pre-filled with settings from an existing item.

builder = ItemBuilder.from_item(existing_item)
upgraded = builder.enchant("SHARPNESS", 10).build()

Chain Methods

All chain methods return the builder, so you can chain them:

item = (
    ItemBuilder("IRON_CHESTPLATE")
    .name("§bFrost Armor")
    .lore("§7Chills attackers")
    .enchant("PROTECTION", 4)
    .enchant("THORNS", 3)
    .unbreakable()
    .custom_model_data(1001)
    .add_attribute("GENERIC_ARMOR", 12, "ADD_NUMBER")
    .flag("HIDE_ENCHANTS", "HIDE_ATTRIBUTES")
    .build()
)

amount

builder.amount(n)

Set the stack size.

name

builder.name(n)

Set the display name.

lore

builder.lore(*lines)

Set lore lines (replaces any existing lore).

add_lore

builder.add_lore(line)

Append a single lore line.

enchant

builder.enchant(enchantment, level=1)

Add an enchantment.

unbreakable

builder.unbreakable(value=True)

Set the unbreakable flag.

glow

builder.glow(value=True)

Add a glow effect (enchantment glint without visible enchantments).

custom_model_data

builder.custom_model_data(value)

Set custom model data for resource packs.

attributes

builder.attributes(attrs)

Set attribute modifiers (replaces any existing).

add_attribute

builder.add_attribute(attribute, amount, operation="ADD_NUMBER")

Add a single attribute modifier.

nbt

builder.nbt(data)

Set raw NBT data.

flag

builder.flag(*flags)

Add item flags to hide information from the tooltip.


build

item = builder.build()

Construct the final Item from the builder state.

Note: build() is synchronous. The resulting Item can be used immediately in inventory operations, give, drop, etc.