Appearance
helix / ItemValue
Class: ItemValue โ
Defined in: core/values/item/value.ts:22
An item: id plus its name, model, enchantments, lore and components.
Pass the same object to give and to predicates; it renders per version (components on 1.20.5+, NBT before) and per use (stack string or predicate JSON).
const excalibur = Item.DIAMOND_SWORD .named("Excalibur").enchant("sharpness", 5).modelData(1234);
ctx.playerGive(Selector.nearest(), excalibur); // give ...[components] 1 ctx.if(predicateCheck(dp.predicate("excalibur", // if predicate ... run ... Predicate.matchTool(excalibur))), ...);
Extends โ
Constructors โ
Constructor โ
new ItemValue(
id):ItemValue
Defined in: core/values/item/builder.ts:44
Parameters โ
id โ
string
Returns โ
ItemValue
Inherited from โ
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.
Inherited from โ
Methods โ
bare() โ
bare():
ItemValue
Defined in: core/values/item/value.ts:29
A new item with only this one's id, dropping its data.
Returns โ
ItemValue
baseId() โ
baseId():
string
Defined in: core/values/item/value.ts:24
The normalized item id with no data/components (minecraft:diamond, #minecraft:planks).
Returns โ
string
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
Inherited from โ
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
Inherited from โ
ItemBuilder.chargedProjectiles
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
Inherited from โ
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
Inherited from โ
copy() โ
copy():
ItemValue
Defined in: core/values/item/value.ts:40
A separate copy, so setting it up for one use leaves this item as it was.
Returns โ
ItemValue
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
Inherited from โ
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
Inherited from โ
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
Inherited from โ
displayName() โ
displayName():
TextComponent|undefined
Defined in: core/values/item/value.ts:59
The name it shows: its custom name, else its item name, if either is set.
Returns โ
TextComponent | undefined
enchant() โ
enchant(
enchantment,level):this
Defined in: core/values/item/builder.ts:96
Add an enchantment + level (repeatable).
Parameters โ
enchantment โ
level โ
number
Returns โ
this
Inherited from โ
firework() โ
firework(
value):this
Defined in: core/values/item/builder.ts:269
The minecraft:fireworks component - see Firework.
Parameters โ
value โ
Returns โ
this
Inherited from โ
getCount() โ
getCount():
number|undefined
Defined in: core/values/item/value.ts:64
The count set via count, if any.
Returns โ
number | undefined
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
Inherited from โ
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
Inherited from โ
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
Inherited from โ
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
Inherited from โ
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
Inherited from โ
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
Inherited from โ
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
Inherited from โ
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
Inherited from โ
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
Inherited from โ
modelId() โ
modelId():
string|undefined
Defined in: core/values/item/value.ts:34
The item_model id set with model, if any (minecraft:spyglass).
Returns โ
string | undefined
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
Inherited from โ
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
Inherited from โ
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
Inherited from โ
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
Inherited from โ
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
Inherited from โ
stackNbt() โ
stackNbt(
opts?):ItemStackNbt
Defined in: core/values/item/value.ts:75
This item as an item-stack NBT compound, for use inside Nbt({ Item: ... }).
match: true gives what an entity's stored stack is tested against with nbt=: no count, and for a matchByData item only its id and custom_data, since NBT tests match compounds partially but lists exactly.
Parameters โ
opts? โ
match? โ
boolean
Returns โ
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
Inherited from โ
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
Inherited from โ
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