-
Notifications
You must be signed in to change notification settings - Fork 2
ItemBuilder
Julian Weinelt edited this page Jun 13, 2025
·
3 revisions
ItemBuilder is a fluent utility class designed to make the creation and customization of ItemStacks in Minecraft easier and more readable.
To begin using the ItemBuilder, simply create a new instance by passing a Material:
ItemBuilder builder = new ItemBuilder(Material.DIAMOND_SWORD);You can then chain various methods to configure the item.
| Method | Description |
|---|---|
| builder.amount(int amount) | Sets the stack size. |
| builder.displayName(String name)builder.displayName(Component component) | Sets the display name of the item. |
| builder.lore(String... lore) | Sets the lore (tooltip lines) below the item name. |
| builder.customModelData(int cmd) | Applies custom model data (1.14+ / up to 1.20.x). |
| builder.enchant(Enchantment... enchantments) | Adds one or more enchantments. |
| builder.flag(ItemFlag flag)builder.flags(ItemFlag... flags) | Adds one or more ItemFlags to the item. |
// Example 1: Creating a custom player head
public ItemStack getPlayerHead(Player player) {
return new ItemBuilder(Material.PLAYER_HEAD)
.owner(player)
.displayName("§aHead")
.build();
}
// Example 2: Creating armor with trim
public ItemStack getArmor(Material material, ArmorTrim trim) {
return new ItemBuilder(material)
.trim(trim)
.build();
}- All methods are chainable for clean and concise syntax.
- Remember to call
.build()at the end to retrieve the finalItemStack.