Appearance
Items
An Item is defined once and works in give, predicates and loot tables for every version.
ts
const excalibur = Item.DIAMOND_SWORD.named("Excalibur").enchant(Enchantment.SHARPNESS, 5);| Method | Sets |
|---|---|
.named(name) | custom_name (string or styled text) |
.lore(...lines) | lore lines |
.enchant(id, level) | one enchantment (repeatable) |
.count(n) | stack size |
.model(ref) | item_model (from dp.model) |
.modelData(n) | raw custom_model_data |
.set(id, value) | any vanilla component, typed from the game schema |
Item.tag(...) makes an item tag.
Give an item
ts
import { Datapack, v26_2, Selector, Item, Enchantment } from "helix";
const dp = new Datapack("loot", v26_2);
dp.createFunction("grant").build((ctx) => {
const excalibur = Item.DIAMOND_SWORD.named({ text: "Excalibur", color: "aqua", italic: false })
.enchant(Enchantment.SHARPNESS, 5)
.lore("Pulled from the stone");
ctx.playerGive(Selector.nearest(), excalibur);
});Compiled output - the real files helix emits for the code above:
txt
give @p minecraft:diamond_sword[custom_name={"text":"Excalibur","color":"aqua","italic":false},enchantments={"minecraft:sharpness":5},lore=[{"text":"Pulled from the stone"}]] 1txt
{
"pack": {
"description": "loot\nCreated using Helix",
"min_format": [
107,
1
],
"max_format": [
107,
1
]
}
}Set any component
ts
Item.STICK.set("max_damage", 5).set("rarity", "epic");WARNING
A component the target version lacks fails the build.
Check for an item
Pass the same item to Predicate.holding or Trigger.usingItem, and it matches what you gave.