Class ItemBuilder
java.lang.Object
me.agent.vgui.api.item.ItemBuilder
Fluent builder for PacketEvents
ItemStacks that writes both modern
item components (1.20.5+) and legacy NBT tags, so items render correctly on every
client version from 1.8 to the latest.
ItemStack sword = ItemBuilder.of(ItemTypes.DIAMOND_SWORD)
.name(Component.text("Excalibur", NamedTextColor.GOLD))
.lore(Component.text("Legendary"), Component.text("Click to buy"))
.glow()
.build();
-
Method Summary
Modifier and TypeMethodDescriptionamount(int amount) Sets the stack size (clamped to [1, 99]).asItem()Shortcut forViewItem.of(build()).com.github.retrooper.packetevents.protocol.item.ItemStackbuild()Builds the item stack.customModelData(int data) Sets custom model data (resource-pack driven models, 1.14+).Escape hatch: mutate the underlying PacketEvents builder directly.glow()Gives the item an enchantment glint without a visible enchantment.glow(boolean glow) Sets or removes the enchantment glint override.legacyData(int legacyData) Sets legacy item data (durability or metadata) for pre-1.13 clients.Sets the lore lines.lore(net.kyori.adventure.text.Component... lore) Sets the lore lines.name(net.kyori.adventure.text.Component name) Sets the display name.static ItemBuilderof(com.github.retrooper.packetevents.protocol.item.type.ItemType type) Starts building an item of the given type with amount 1.static ItemBuilderof(com.github.retrooper.packetevents.protocol.item.type.ItemType type, int amount) Starts building an item of the given type and amount (clamped to [1, 99]).onClick(Consumer<ClickContext> onClick) Shortcut forViewItem.clickable(build(), onClick).skullOwner(String playerName) Sets a player-head skin by player name.skullTexture(String base64Texture) Sets a player-head texture from a base64 texture value (theValuefield of atexturesproperty, as found on skin sites).Marks the item unbreakable (also hides the durability bar).
-
Method Details
-
of
Starts building an item of the given type with amount 1. -
of
public static ItemBuilder of(com.github.retrooper.packetevents.protocol.item.type.ItemType type, int amount) Starts building an item of the given type and amount (clamped to [1, 99]). -
name
Sets the display name. -
lore
Sets the lore lines. -
lore
Sets the lore lines. -
amount
Sets the stack size (clamped to [1, 99]). -
glow
Gives the item an enchantment glint without a visible enchantment. -
glow
Sets or removes the enchantment glint override. -
customModelData
Sets custom model data (resource-pack driven models, 1.14+). -
unbreakable
Marks the item unbreakable (also hides the durability bar). -
skullTexture
Sets a player-head texture from a base64 texture value (theValuefield of atexturesproperty, as found on skin sites). Only meaningful forPLAYER_HEADitems. SeeSkulls.texturedHead(String)for a shortcut. -
skullOwner
Sets a player-head skin by player name. The client resolves the skin itself (works for premium account names). -
legacyData
Sets legacy item data (durability or metadata) for pre-1.13 clients. For example,14makes aSTAINED_GLASS_PANEred. Modern clients ignore it. -
edit
public ItemBuilder edit(Consumer<com.github.retrooper.packetevents.protocol.item.ItemStack.Builder> editor) Escape hatch: mutate the underlying PacketEvents builder directly. -
build
public com.github.retrooper.packetevents.protocol.item.ItemStack build()Builds the item stack. The builder can be reused afterwards. -
asItem
Shortcut forViewItem.of(build()). -
onClick
Shortcut forViewItem.clickable(build(), onClick).
-