Appearance
helix / LootFunction
Class: LootFunction
Defined in: core/values/loot-function.ts:19
One loot function - a transform applied to a generated item stack. The same vocabulary is used inside loot-table entries/pools (LootTable) and as the whole body of an ItemModifier, so it is defined once here and shared.
Functions are built from typed concepts (an ItemValue's own components, not hand-written JSON) wherever a value object can supply them.
LootFunction.setCount(4) LootFunction.setComponents(Item.DIAMOND_SWORD.named("Excalibur"))
Methods
toJson()
toJson(
version):Record<string,unknown>
Defined in: core/values/loot-function.ts:25
The function JSON, with embedded values rendered for version.
Parameters
version
Returns
Record<string, unknown>
enchantWithLevels()
staticenchantWithLevels(levels,treasure?):LootFunction
Defined in: core/values/loot-function.ts:52
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:61
minecraft:furnace_smelt - replace with the item's smelting result.
Returns
LootFunction
of()
staticof(fn,fields?):LootFunction
Defined in: core/values/loot-function.ts:70
Escape hatch: a function by id with already-built fields, e.g. LootFunction.of("set_name", { name: "Boss Loot" }). minecraft: is added to a bare id.
Parameters
fn
string
fields?
Record<string, unknown> = {}
Returns
LootFunction
setComponents()
staticsetComponents(item):LootFunction
Defined in: core/values/loot-function.ts:44
minecraft:set_components - apply item's data components to the stack, reusing the item's own component definitions (ItemValue.componentsJson) so a loot drop carries the exact components the same item would give. No-op JSON on pre-component versions.
Parameters
item
Returns
LootFunction
setCount()
staticsetCount(count,add?):LootFunction
Defined in: core/values/loot-function.ts:30
minecraft:set_count - set (or, with add, increment) the stack size.
Parameters
count
add?
boolean = false
Returns
LootFunction