Appearance
helix / ItemBuilder
Class: ItemBuilder โ
Defined in: core/values/item/builder.ts:40
The setters of ItemValue; each returns the item for chaining.
Extends โ
Extended by โ
Constructors โ
Constructor โ
new ItemBuilder(
id):ItemBuilder
Defined in: core/values/item/builder.ts:44
Parameters โ
id โ
string
Returns โ
ItemBuilder
Overrides โ
Properties โ
lowered โ
protectedreadonlylowered:true=true
Defined in: core/values/value.ts:14
Tells lowered values apart from plain objects (e.g. NBT compounds).
Inherited from โ
s โ
readonlys:ItemState
Defined in: core/values/item/builder.ts:42
The item's settings, read by the IR when it renders the item.
Methods โ
canPlaceOn() โ
canPlaceOn(...
blocks):this
Defined in: core/values/item/builder.ts:151
Blocks this item can be placed on in adventure mode, e.g. Block.STONE or Block.tag(BLOCK_TAGS.STONE_BRICKS).
Renders as the can_place_on component on 1.20.5+, CanPlaceOn NBT before.
Parameters โ
blocks โ
...(string | BlockValue<string>)[]
Returns โ
this
chargedProjectiles() โ
chargedProjectiles(...
items):this
Defined in: core/values/item/builder.ts:263
minecraft:charged_projectiles: what a crossbow is loaded with, which also makes it render loaded.
Parameters โ
items โ
...ItemValue[]
Returns โ
this
consumable() โ
consumable(
spec):this
Defined in: core/values/item/builder.ts:203
minecraft:consumable (1.21.2+): makes the item usable, which fires Trigger.usingItem every tick it's held in use. A huge consumeSeconds with ItemUseAnimation.NONE gives a right-click item that's never eaten.
Parameters โ
spec โ
Returns โ
this
container() โ
container(
slots):this
Defined in: core/values/item/builder.ts:193
minecraft:container: what a placed chest, barrel or shulker box holds, by slot.
Parameters โ
slots โ
Record<number, ItemValue>
Returns โ
this
count() โ
count(
n):this
Defined in: core/values/item/builder.ts:61
Stack size carried with the item (used by give; a count range for predicates).
Parameters โ
n โ
number
Returns โ
this
customData() โ
customData(
value):this
Defined in: core/values/item/builder.ts:164
minecraft:custom_data: pack-owned data on the stack. Merges into what's there.
Matches exactly in item predicates; use .subPredicate("custom_data", ...) for a partial match, or matchByData.
Parameters โ
value โ
Returns โ
this
damageResistant() โ
damageResistant(
types):this
Defined in: core/values/item/builder.ts:220
minecraft:damage_resistant: damage types the dropped item survives, as a damage-type tag, e.g. DAMAGE_TYPE_TAGS.IS_FIRE. The # is optional.
Parameters โ
types โ
"minecraft:mace_smash" | "minecraft:wither_immune_to" | "minecraft:always_hurts_ender_dragons" | "minecraft:always_kills_armor_stands" | "minecraft:always_most_significant_fall" | "minecraft:always_triggers_silverfish" | "minecraft:avoids_guardian_thorns" | "minecraft:burn_from_stepping" | "minecraft:burns_armor_stands" | "minecraft:bypasses_armor" | "minecraft:bypasses_cooldown" | "minecraft:bypasses_effects" | "minecraft:bypasses_enchantments" | "minecraft:bypasses_invulnerability" | "minecraft:bypasses_resistance" | "minecraft:bypasses_shield" | "minecraft:bypasses_wolf_armor" | "minecraft:can_break_armor_stand" | "minecraft:damages_helmet" | "minecraft:ignites_armor_stands" | "minecraft:is_drowning" | "minecraft:is_explosion" | "minecraft:is_fall" | "minecraft:is_fire" | "minecraft:is_freezing" | "minecraft:is_lightning" | "minecraft:is_player_attack" | "minecraft:is_projectile" | "minecraft:no_anger" | "minecraft:no_hurt_sound" | "minecraft:no_impact" | "minecraft:no_knockback" | "minecraft:no_wolf_retaliation" | "minecraft:panic_causes" | "minecraft:panic_environmental_causes" | "minecraft:sulfur_cube_with_block_immune_to" | "minecraft:witch_resistant_to" | string & object
Returns โ
this
enchant() โ
enchant(
enchantment,level):this
Defined in: core/values/item/builder.ts:96
Add an enchantment + level (repeatable).
Parameters โ
enchantment โ
level โ
number
Returns โ
this
firework() โ
firework(
value):this
Defined in: core/values/item/builder.ts:269
The minecraft:fireworks component - see Firework.
Parameters โ
value โ
Returns โ
this
hasComponent() โ
hasComponent(
type):this
Defined in: core/values/item/builder.ts:322
Predicate-only: the item has the type component at all, whatever its value (id[type]). Command item predicates only; JSON predicates can't say it. Throws before 1.20.5.
Parameters โ
type โ
Returns โ
this
hasEnchantment() โ
hasEnchantment(
enchantment):this
Defined in: core/values/item/builder.ts:328
Predicate-only: the item has enchantment at any level.
Parameters โ
enchantment โ
Returns โ
this
hideTooltip() โ
hideTooltip(...
components):this
Defined in: core/values/item/builder.ts:235
Hides these components' lines from the tooltip (tooltip_display, 1.21.5+), e.g. DataComponentType.ENCHANTMENTS; with none, hides the whole tooltip. Throws on older versions.
Parameters โ
components โ
...(string | DataComponentType)[]
Returns โ
this
itemName() โ
itemName(
name):this
Defined in: core/values/item/builder.ts:73
item_name: the item's default name, which anvils can't rename and doesn't show in italics.
Parameters โ
name โ
Returns โ
this
lore() โ
lore(...
lines):this
Defined in: core/values/item/builder.ts:102
Append lore lines (lore / display.Lore). Each line is a string or styled TextComponent.
Parameters โ
lines โ
...TextComponent[]
Returns โ
this
matchByData() โ
matchByData():
this
Defined in: core/values/item/builder.ts:176
Item predicates for this item test only its id and custom_data, so a renamed or edited stack still matches.
Returns โ
this
maxStackSize() โ
maxStackSize(
n):this
Defined in: core/values/item/builder.ts:209
minecraft:max_stack_size: how many fit in one slot (1-99).
Parameters โ
n โ
number
Returns โ
this
model() โ
model(
handle):this
Defined in: core/values/item/builder.ts:90
Points the item at a model by ref or <ns>:name. Renders as item_model on 1.21.4+; older versions need the ref's legacy custom_model_data number or it throws.
Parameters โ
handle โ
string | ModelRef
Returns โ
this
modelData() โ
modelData(
n):this
Defined in: core/values/item/builder.ts:81
Raw custom_model_data integer, for externally managed models. Prefer model.
Parameters โ
n โ
number
Returns โ
this
named() โ
named(
name):this
Defined in: core/values/item/builder.ts:67
custom_name / display.Name. Accepts a plain string or a styled TextComponent.
Parameters โ
name โ
Returns โ
this
potionContents() โ
potionContents(
spec):this
Defined in: core/values/item/builder.ts:182
minecraft:potion_contents with a custom colour and effects, as on a tipped arrow or potion.
Parameters โ
spec โ
Returns โ
this
remove() โ
remove(...
components):this
Defined in: core/values/item/builder.ts:139
Drops components from the stack it lands on, as !minecraft:x, e.g. a glint override set earlier. Only for stacks it writes (give, set_components), not predicates.
Parameters โ
components โ
...DataComponentType[]
Returns โ
this
replaceLore() โ
replaceLore(...
lines):this
Defined in: core/values/item/builder.ts:108
Replace all lore lines, e.g. on a copy that shouldn't keep the original's.
Parameters โ
lines โ
...TextComponent[]
Returns โ
this
set() โ
set<
K>(id,value):this
Defined in: core/values/item/builder.ts:278
Sets any vanilla component, typed from vanilla-mcdoc: Item.STICK.set("max_damage", 5). Keys are camelCase; changed forms are written per version, and a component the target lacks throws. Setting one again replaces it.
Type Parameters โ
K โ
K extends keyof ComponentValues
Parameters โ
id โ
K | `minecraft:${K}`
value โ
Returns โ
this
subPredicate() โ
subPredicate(
type,json):this
Defined in: core/values/item/builder.ts:313
An item sub-predicate: asks about a component instead of matching it exactly.
Item.DIAMOND_SWORD.subPredicate("enchantments", [{}]) // any enchantment Item.DIAMOND_SWORD.subPredicate("damage", { durability: { min: 1 } })
Predicate-only; ignored when rendering a stack. For "absent", wrap in Predicate.not(...). Throws before 1.20.5.
Parameters โ
type โ
string
json โ
unknown
Returns โ
this
without() โ
without(...
components):this
Defined in: core/values/item/builder.ts:114
Remove components, e.g. ones a set_components shouldn't overwrite on a player's stack.
Parameters โ
components โ
...DataComponentType[]
Returns โ
this
writtenBook() โ
writtenBook(
title,author,pages,generation?):this
Defined in: core/values/item/builder.ts:249
minecraft:written_book_content: title, author and pages.
Each page is a string, a styled span, or an array of spans, rendered in the version's page form. generation is 0 (original) to 3 (tattered). Throws before 1.20.5.
Parameters โ
title โ
string
author โ
string
pages โ
(string | TellrawPart | TellrawPart[])[]
generation? โ
0 | 2 | 1 | 3
Returns โ
this