Appearance
helix / LootFunction
Class: LootFunction โ
Defined in: core/values/loot-function.ts:34
A loot function: a transform on a generated item stack. Shared by loot tables and ItemModifiers.
LootFunction.setCount(4) LootFunction.of("set_name", { name: text("Excalibur"), target: "item_name" })
Properties โ
spec โ
readonlyspec:LootFunctionSpec
Defined in: core/values/loot-function.ts:35
Methods โ
copyCustomData() โ
staticcopyCustomData(id,paths,op?):LootFunction
Defined in: core/values/loot-function.ts:95
minecraft:copy_custom_data from storage id: copies each [from, to] path into the stack's custom_data. The only way to write a runtime value onto a player's item.
Parameters โ
id โ
paths โ
[NbtPathValue, NbtPathValue][]
op? โ
"merge" | "append" | "replace"
Returns โ
LootFunction
enchantWithLevels() โ
staticenchantWithLevels(levels,treasure?):LootFunction
Defined in: core/values/loot-function.ts:103
minecraft:enchant_with_levels - enchant as if at levels (optionally treasure).
Parameters โ
levels โ
treasure? โ
boolean = false
Returns โ
LootFunction
furnaceSmelt() โ
staticfurnaceSmelt():LootFunction
Defined in: core/values/loot-function.ts:119
minecraft:furnace_smelt - replace with the item's smelting result.
Returns โ
LootFunction
of() โ
staticof<K>(id, ...args):LootFunction
Defined in: core/values/loot-function.ts:41
Any vanilla loot function, with its arguments typed from vanilla-mcdoc. Keys are camelCase; renamed keys and changed forms are written per version, and one the target lacks throws.
Type Parameters โ
K โ
K extends keyof LootFunctionArgs
Parameters โ
id โ
K | `minecraft:${K}`
args โ
...object extends LootFunctionArgs[K] ? [LootFunctionArgs[K]?] : [LootFunctionArgs[K]]
Returns โ
LootFunction
raw() โ
staticraw(fn,fields?):LootFunction
Defined in: core/values/loot-function.ts:51
A function by id with prebuilt JSON fields, for ones vanilla doesn't have.
Parameters โ
fn โ
string
fields? โ
Record<string, unknown> = {}
Returns โ
LootFunction
setComponents() โ
staticsetComponents(item):LootFunction
Defined in: core/values/loot-function.ts:61
minecraft:set_components: applies item's components, the same ones give would.
Parameters โ
item โ
Returns โ
LootFunction
setCount() โ
staticsetCount(count,add?):LootFunction
Defined in: core/values/loot-function.ts:56
minecraft:set_count - set (or, with add, increment) the stack size.
Parameters โ
count โ
add? โ
boolean = false
Returns โ
LootFunction
setCustomData() โ
staticsetCustomData(tag):LootFunction
Defined in: core/values/loot-function.ts:77
minecraft:set_custom_data: merges tag into the stack's custom_data.
Parameters โ
tag โ
Returns โ
LootFunction
setEnchantments() โ
staticsetEnchantments(levels,add?):LootFunction
Defined in: core/values/loot-function.ts:69
minecraft:set_enchantments: sets each enchantment to a level; level 0 removes it. With add, levels add to the current ones.
Parameters โ
levels โ
[Enchantment, number][]
add? โ
boolean = false
Returns โ
LootFunction
setItem() โ
staticsetItem(like):LootFunction
Defined in: core/values/loot-function.ts:111
minecraft:set_item: changes the stack's item type, keeping its count and components. Takes a bare item: the function sets only the type, so components on item would be lost.
Parameters โ
like โ
Returns โ
LootFunction
setLore() โ
staticsetLore(lines,entity?):LootFunction
Defined in: core/values/loot-function.ts:87
minecraft:set_lore: replaces the lore with lines.
Score, selector and NBT spans are filled in as entity when the function runs, so item modify can write live values into a tooltip.
Parameters โ
lines โ
TextLike[]
entity? โ
LootEntity = "this"
Returns โ
LootFunction