API reference / @jsprismarine/loot
@jsprismarine/loot
The Java Edition loot table evaluator. It parses the 1447 vanilla tables of Java 26.3 once into closures and rolls them against a context, reproducing Java's draw order, weight formula and random sequence seeding.
Java conditions and item modifiers are implemented by @jsprismarine/predicates, and this package composes them. It also reads Bedrock behavior-pack tables for data-driven entity equipment and interactions, applying the Bedrock set_count and set_data_from_color_index functions.
Install
pnpm add @jsprismarine/lootRolling one table
import { createLootContext, lootSequenceRandom, parseLootTable, rollLootTable } from '@jsprismarine/loot';
const { value: table, diagnostics } = parseLootTable(json);
const context = createLootContext({
parameterSet: table.parameterSet,
parameters: { origin: { x: 0, y: 64, z: 0 }, block_state: { name: 'minecraft:coal_ore' }, tool },
random: lootSequenceRandom(worldSeed, table.randomSequence)
});
rollLootTable(table, context);Parsing never throws. Every fault lands in the returned diagnostics and the table rolls to whatever is still well formed, which is the same contract @jsprismarine/predicates has. Pass strict: true to get a LootGrammarError instead, listing every error, for a host that would rather refuse a table than roll it half-read.
Most servers will use the registry instead, because it already knows the world seed, the pack stack and each table's own context key set:
import { LootRegistry, javaLootTables } from '@jsprismarine/loot';
import { load } from '@jsprismarine/packs';
const { definitions } = load(stack);
const loot = new LootRegistry(
{ ...definitions, lootTables: javaLootTables(definitions.lootTablesJava) },
{ worldSeed: 1234n }
);
loot.validate(); // compiles every table and reports reference cycles
loot.roll('minecraft:blocks/coal_ore', { parameters: { origin, block_state, tool } });Grammar coverage
| Registry | 26.3 registers | This package | Vanilla uses |
|---|---|---|---|
loot_pool_entry_type | 9 | 9 | 6 |
loot_condition_type | 20 | through @jsprismarine/predicates | 13 |
loot_function_type | 42 | through @jsprismarine/predicates | 19 |
The nine entry types are item, tag, loot_table, dynamic, slots, empty, group, alternatives and sequence. The original brief for this package listed eight and left the ninth open; the ninth is slots, which 26.3 added with the slot_source registry. Vanilla ships no slot source files and uses no slots entry, so this package parses the entry and hands its slot_source JSON to an injected view rather than implementing a slot model it has nothing to check against.
dynamic is the other entry whose body lives outside this package. Java calls these dynamic drops and uses them for contents a block entity carries into its own drop, such as a shulker box's inventory. There is one in vanilla, minecraft:blocks/decorated_pot for its sherds.
Counts come from the corpus test described below, and agree with the registry research note section 3.
What 26.3 renamed
If you are reading older loot documentation, four field names have moved, and this package follows the 26.3 jar rather than the wiki:
functionsis nowmodifier, on the table, the pool and the entry alike.conditionsis nowcondition.- A
loot_tableentry names its target invalue, notname, and the value may be an inline table, an id, a list, or a#tag. - A
tagentry names its items initems, notname.
A table with no type falls back to the generic context key set, which is what LootContextParamSets.ALL_PARAMS is registered as.
What an unread key does
A loot table is gated data, so the two ways a gate goes missing both matter here, and both used to go unreported.
A key the grammar has no case for is an error. Nothing reads it, so it changes the file's meaning and not the roll, and a condition list sitting unread beside a pool is indistinguishable from a pool with no gate at all. The report names the key and the level it sat at:
pools[0].conditions: the java loot pool grammar has no conditions member, so nothing reads itThe table still rolls everything it could read, so one stray key does not empty a chest. The 1447 vanilla tables report nothing, which is what keeps the rule honest: every key they use is a key this package acts on.
A condition the grammar cannot compile closes its gate. 26.3's composition rule folds a condition field with and, and a term that fails to compile drops out of the fold, so a field holding one unimplemented condition folds to an empty and and passes. That is the wrong direction for loot to fail in. Any error raised while compiling a condition field closes that gate for good, at the pool and at the entry alike, and the error that closed it is already in the diagnostics.
The Bedrock dialect
Bedrock's behavior packs carry loot tables of their own, in the spelling Java used before 26.3 renamed four fields. bedrockLootTables reads that spelling. Java's path is untouched, because the 1447 datapack tables are this project's gameplay source.
const equipment = new LootRegistry(
{ ...definitions, lootTables: bedrockLootTables(definitions.lootTables) },
{ worldSeed }
);
equipment.roll('loot_tables/entities/zombie_equipment.json');The dialect is a member of the source rather than an option beside it, and there is no third way to build a source. Both editions' tables are ReadonlyMap<string, unknown>, so while the two were stated separately nothing could tell a host that had paired the wrong two — and one had: the Bedrock map went into a field named lootTablesJava, and only a dialect: 'bedrock' written six lines away kept it right. Pairing them in the value is what makes that a compile error.
What the two dialects spell differently:
| Java 26.3 | Bedrock | |
|---|---|---|
| A pool's or entry's gate | condition | conditions, an array, each member naming its type in a condition key |
| A pool's draw | rolls and candidate weights | tiers, a ladder, for ten of the 309 tables |
| A range | { "type": "minecraft:uniform", "min": 2, "max": 4 } | { "min": 2, "max": 4 }, read as that same uniform provider |
| An item entry's stack count | a set_count function | count on the entry, a number or a range |
A loot_table entry's target | value, composable | name, the pack-relative path, with or without the .json |
| An entry's nested rolls | none | pools, rolled once the entry is drawn |
| An entry's modifiers | modifier | functions; set_count and set_data_from_color_index are applied, while other reviewed functions warn and are skipped |
Three conditions are implemented, the three the equipment tables gate on: random_chance, random_difficulty_chance and random_regional_difficulty_chance. Nothing else is read silently, which is the point of the previous section.
Reviewed gaps
BEDROCK_REVIEWED_CONDITIONS lists twelve condition types that read an entity or biome this roll cannot provide, and BEDROCK_REVIEWED_FUNCTIONS lists the 17 item functions still unimplemented. Each entry names what a result comes out as without it. A listed condition closes its gate and warns; a listed function is skipped and warns. BEDROCK_IMPLEMENTED_FUNCTIONS names the two functions already applied: set_count and set_data_from_color_index. anything unlisted is an error, because a reviewed gap has a bounded effect and an unreviewed one does not. That is the same rule the unread-key report applies, and it is what lets strict refuse a pack carrying something new without refusing a stock Bedrock server: over all 309 vanilla tables the registry reports 1484 warnings and no errors.
The runtime rolls Bedrock equipment tables and interaction tables such as the sheep's shearing table. It applies stack counts and copies minecraft:color into Bedrock item auxiliary data, so a sheared sheep drops the correct wool color and count. Other functions remain reported gaps; for example, mob equipment still skips enchant_random_gear and looting_enchant, so a skeleton's bow arrives unenchanted.
tiers reproduces Java's Mob.populateArmor. The draw lands in initial_range counted from the first entry, then climbs one rung per bonus_rolls that beats bonus_chance, stopping at the last entry. zombie_equipment.json states a range of 3 over six armor sets with three bonus rolls at 0.1087, so leather, copper and gold are common and diamond needs all three bonuses.
The two difficulty-scaled conditions read a LootDifficultyView. Without one they see normal difficulty in a fully ramped region, which makes a table's stated max_chance its actual chance: zombie_equipment.json arms one zombie in twenty from its 0.05, measured at 99 of 2000.
Evaluation order
One roll walks the table in Java's order, and the order is observable, so it is worth stating exactly.
- The table's pools run in file order.
- A pool whose
conditionfails is skipped whole. - A pool rolls
rollsplusfloor(bonus_rolls * luck)times. The multiplication happens in 32-bit float arithmetic and is floored afterwards, sobonus_rollsof 0.6 adds nothing at luck 1 and two rolls at luck 4. - Each roll expands every entry container in the pool into candidates. A container whose own
conditionfails contributes none.alternativesstops at the first child that contributes,sequencestops at the first child that does not, andgroupruns all of them. - A candidate's weight is
floor(weight + quality * luck), clamped at zero, again in float arithmetic. Candidates of weight zero are dropped before the draw. - One candidate is drawn in proportion to weight. With a single candidate, Java skips the draw and takes it, which matters because it consumes no randomness.
- Each stack the candidate produces passes through the entry's
modifier, then the pool's, then the table's. A modifier that discards a stack ends it there. - Results above the item's maximum stack size are split into whole stacks and a remainder, which is what Java's public roll does. Pass
split: falsefor the raw list.
The seeding rule
A table names a random_sequence, and Java keeps one stream per sequence id for the world. The stream is a Xoroshiro128++ generator seeded from the world seed upgraded to 128 bits, exclusive-ored with the MD5 hash of the sequence id, then mixed with Stafford variant 13 on both halves. That is reproduced bit for bit here, and random.test.ts checks the draws against Java oracle vectors.
Two consequences a server has to get right. Two worlds with the same seed break the same ore into the same drops, and two tables in one world never share a stream. Rolling one table twice must not replay the same draws, so LootRegistry creates each stream once and lets it advance, the way Java's RandomSequences does. Tables that name no sequence share one unkeyed stream, standing in for Java's level random.
import { lootSequenceRandom } from '@jsprismarine/loot';
lootSequenceRandom(1234n, 'minecraft:blocks/coal_ore'); // the stream that table draws from
lootSequenceRandom(1234n); // the fallback for a table with no sequenceInjectable seams
Every seam is optional. A table that reaches one the host left out reports a diagnostic and produces nothing there, rather than failing the roll.
- The random source. Rolling uses only
context.random, so a scripted or seeded source reproduces a draw exactly. That is what makes the distribution tests here exact counts rather than samples. ItemStackOps, from@jsprismarine/predicates, owns stack construction, optional Bedrock auxiliary data, the stack size limit, and component writes. The splitter in step 8 asks it formaxStackSize.DynamicDropSourceanswers adynamicentry, keyed by the name the entry carries.SlotSourceViewanswers aslotsentry from its rawslot_sourceJSON.LootContentOptionsfills the content view described in the next section.LootPackDefinitionsis the pack stack the registry reads. Every member butlootTablesis structural, so you spreadDefinitionsfrom@jsprismarine/packsin and override that one withjavaLootTables(...)orbedrockLootTables(...); this package keeps no dependency on the loader.LootTableSourceis a loot table map and the dialect it is written in, together. Build one withjavaLootTablesorbedrockLootTables.ItemIdentifierMappertranslates a result to Bedrock, covered below.
The content view
@jsprismarine/predicates declares a ContentView with five members it deliberately left for this package, because all five turn out to be loot questions. createLootContext builds the view and wires it into a predicate context, which is the only way to close the loop set_contents needs: rolling its nested entries takes the very context whose content view is being built.
| Member | Who answers it | Default |
|---|---|---|
smeltingResult | furnace_smelt | Indexed from the minecraft:smelting recipes you pass in. Without recipes the modifier reports and leaves the stack alone. |
rollEntries | set_contents | This package's own entry grammar, rolled against the same context. Always available. |
dyeColors | set_random_dyes | DYE_COLORS, the 16 DyeColor.textureDiffuseColor values of Java 26.3 in registry order. |
profileOf | fill_player_head | The entity's own minecraft:profile component. Override with profiles. |
explorationMap | exploration_map | Needs a structures locator. Given one, it writes minecraft:map_id from your allocator and a minecraft:map_decorations entry keyed "+" at rotation 180, matching Java's addTargetDecoration. |
const context = createLootContext({
parameterSet: 'chest',
parameters,
content: {
recipes: definitions.recipesJava,
itemTag: (tag) => myTags.get(tag),
structures: (request) => myWorld.findStructure(request.destination, request.searchRadius),
mapIds: () => myMaps.allocate()
}
});Smelting results follow Java: the recipe's own result and count, not a copy of the input, and the first recipe to claim an ingredient wins. Tagged ingredients need itemTag; vanilla's 73 smelting recipes all name plain items, so the seam only matters for a datapack that adds one.
References and cycles
26.3 removed the reference condition and function and made every composable field accept an inline value, a namespaced id, a list mixing both, or a #tag. A loot_table entry's value goes through the same rule, so one entry can name several tables at once, and expand: true turns each into its own weighted candidate instead of rolling them all.
A reference that leads back to the table it started from reports a cycle instead of recursing. The registry finds cycles two ways. During a parse, the composition helper catches a reference already on the stack and reports it at the field that closed the loop. Separately, LootRegistry.cycles walks the raw JSON without compiling anything and gives each cycle as the chain that closes it, which validate() turns into a diagnostic:
loot table reference cycle: minecraft:a -> minecraft:b -> minecraft:aThe vanilla stack has 57 loot_table entries pointing at other tables, and no cycles.
Translating to Bedrock
A rolled result carries Java item identifiers. mapLootToBedrock translates it through an injected lookup, and javaItemToBedrock from @jsprismarine/mapping satisfies that lookup as it is. The mapping package stays a development dependency here, so this package never learns that two editions exist.
import { javaItemToBedrock } from '@jsprismarine/mapping';
import { mapLootToBedrock } from '@jsprismarine/loot';
const { stacks, losses } = mapLootToBedrock(loot.roll(id, request), javaItemToBedrock);Nothing is dropped silently. A reviewed loss keeps the fallback item listed in @jsprismarine/mapping and reports one entry with the reason and its reference; an identifier the pinned Java version does not have is dropped and reports a loss of kind unknown. Losses come back one per affected stack, in the order the roll produced them, so a report can name the table that produced each.
Data component payloads ride along untouched. Translating a component to its Bedrock form belongs to the item layer, not to the loot evaluator.
Corpus test
corpus.test.ts loads the real Java 26.3 vanilla datapack through @jsprismarine/packs, which also checks the pack-stack adapter against the real loader rather than a hand-built double. It measures:
- 1447 tables over 1589 pools, parsing with no diagnostic at all, neither errors nor warnings, and no reference cycles.
- Six of the nine entry types in use:
item2556,alternatives87,loot_table57,empty39,dynamic1,tag1. - Every table rolled 20 times from world seed 1234, throwing nowhere, with 1335 of the 1447 producing at least one stack.
The 112 that produce nothing produce nothing in the game either for that subject. They are the doors, beds and tall plants whose match_block wants a half or part the fixed block state does not carry, the genuinely empty tables (fire, spawner, budding amethyst, armor stand, most passive mobs), and the shearing tables that want a sheep color.
The test needs the cache that pnpm --filter @jsprismarine/bedrock-data run fetch:sources populates, so it only runs with JSP_VANILLA_DATAPACK set and CI without the cache skips it.
bedrockCorpus.test.ts is the same measurement for the Bedrock half, over the 309 tables of the composed BDS vanilla layers, behind JSP_VANILLA_BEHAVIOR_PACK. It pins the defect and its fix as numbers: the Java grammar arms 2000 zombies of 2000 from zombie_equipment.json, the Bedrock dialect arms 99. All 18 tables a minecraft:equipment component names parse with no error and roll something. The whole 309 report 400 unapplied functions, 71 untyped { min, max } providers, and 12 unimplemented condition types, counted so the gap cannot grow unnoticed.
Decisions worth knowing
The random sequence generator is implemented here rather than imported. It is the same Xoroshiro128++ that @jsprismarine/worldgen uses for terrain, but loot has no business depending on the terrain stack for sixty lines of arithmetic. If a third package needs it, the generator should move to a shared package and both should import it from there.
Cycle detection is a parse-time report, not a runtime guard. Java detects the loop at roll time with a visited set and logs "Detected infinite loop in loot tables". Reporting at parse time gives the same outcome, nothing produced at the point of recursion, and tells a pack author about it before a player opens the chest.
The table's declared context key set is checked against the roll's. rollLootTable reports when they disagree, because a table attached to the wrong context is the failure mode that otherwise looks like a table that quietly drops nothing. LootRegistry.roll takes the set from the table, so it never trips on its own.
License
MIT
Classes
Interfaces
BedrockItemReference
Defined in: loot/src/mapping.ts:14
One Bedrock item: the identifier and the legacy damage value when one selects a sub-item.
Properties
data?
readonlyoptionaldata?:number
Defined in: loot/src/mapping.ts:16
identifier
readonlyidentifier:string
Defined in: loot/src/mapping.ts:15
BedrockStack
Defined in: loot/src/mapping.ts:36
One rolled stack after translation.
Properties
components
readonlycomponents:ReadonlyMap<string,unknown>
Defined in: loot/src/mapping.ts:44
The Java data components, carried over untouched. Translating component payloads belongs to the item layer, not to the loot evaluator.
count
readonlycount:number
Defined in: loot/src/mapping.ts:39
data?
readonlyoptionaldata?:number
Defined in: loot/src/mapping.ts:38
identifier
readonlyidentifier:string
Defined in: loot/src/mapping.ts:37
javaId
readonlyjavaId:string
Defined in: loot/src/mapping.ts:46
The Java item the stack came from, kept so a report traces back to the table.
LootContentOptions
Defined in: loot/src/content.ts:36
What the content view needs that neither the predicate context nor this package can derive.
Properties
dyeColors?
readonlyoptionaldyeColors?: readonlynumber[]
Defined in: loot/src/content.ts:56
Overrides DYE_COLORS, for a pack that redefines the palette.
itemTag?
readonlyoptionalitemTag?: (tag) => readonlystring[] |undefined
Defined in: loot/src/content.ts:44
Expands an item tag a smelting ingredient names, without the leading #.
Parameters
tag
string
Returns
readonly string[] | undefined
mapIds?
readonlyoptionalmapIds?: () =>number
Defined in: loot/src/content.ts:48
Allocates the minecraft:map_id an exploration map carries.
Returns
number
parse?
readonlyoptionalparse?:ParseOptions
Defined in: loot/src/content.ts:58
Parse options for the entries a set_contents modifier carries, so they may name references too.
profiles?
readonlyoptionalprofiles?: (entity) =>unknown
Defined in: loot/src/content.ts:54
Reads a player profile off an entity for fill_player_head. The default returns the entity's own minecraft:profile component, which is what a host that already models players has.
Parameters
entity
unknown
Returns
unknown
recipes?
readonlyoptionalrecipes?:ReadonlyMap<string,unknown>
Defined in: loot/src/content.ts:42
Recipes keyed by namespaced id, in the shape a loaded pack stack holds them. furnace_smelt reads the minecraft:smelting members; without them it reports and leaves the stack alone.
structures?
readonlyoptionalstructures?:StructureLocator
Defined in: loot/src/content.ts:46
Where exploration_map searches. Without it the modifier reports and leaves the stack alone.
LootContextOptions
Defined in: loot/src/content.ts:202
Everything createLootContext takes: the predicate context's own options plus this package's.
Extends
Omit<PredicateContextOptions,"content">
Properties
content?
readonlyoptionalcontent?:LootContentOptions
Defined in: loot/src/content.ts:204
What the content view needs. Omitting it still gives the dye table and nested entry rolls.
diagnostics?
optionaldiagnostics?:DiagnosticCollector
Defined in: predicates/src/context.ts:126
Defaults to a fresh collector, reachable as PredicateContext.diagnostics.
Inherited from
Omit.diagnostics
enchantments?
optionalenchantments?:EnchantmentView
Defined in: predicates/src/context.ts:128
Inherited from
Omit.enchantments
items?
optionalitems?:ItemStackOps
Defined in: predicates/src/context.ts:127
Inherited from
Omit.items
level?
optionallevel?:LevelView
Defined in: predicates/src/context.ts:124
Inherited from
Omit.level
luck?
readonlyoptionalluck?:number
Defined in: loot/src/content.ts:209
Java's luck, used by the nested rolls set_contents makes. Pass the same value to the roll, or let LootRegistry pass both for you.
parameters?
optionalparameters?:LootContextParameters
Defined in: predicates/src/context.ts:121
Inherited from
Omit.parameters
parameterSet?
optionalparameterSet?:"chest"|"empty"|"generic"|"command"|"command_slot_source"|"command_compute_default"|"command_compute_position"|"command_compute_entity"|"selector"|"villager_trade"|"fishing"|"entity"|"equipment"|"archaeology"|"gift"|"barter"|"vault"|"advancement_reward"|"advancement_entity"|"advancement_location"|"block_use"|"block"|"shearing"|"entity_interact"|"block_interact"|"container_process"|"enchanted_damage"|"enchanted_item"|"enchanted_location"|"enchanted_entity"|"hit_block"
Defined in: predicates/src/context.ts:120
Defaults to empty, which declares no parameters and so reports every read.
Inherited from
Omit.parameterSet
random?
optionalrandom?:RandomSource
Defined in: predicates/src/context.ts:123
Defaults to a source that always draws 0.5.
Inherited from
Omit.random
LootDifficultyView
Defined in: loot/src/dialect.ts:269
What Bedrock's two difficulty-scaled conditions read.
Both are asked per evaluation rather than captured at parse time, so a world whose difficulty changes takes effect on the next roll instead of on the next reload.
Methods
level()
level():
"peaceful"|"easy"|"normal"|"hard"
Defined in: loot/src/dialect.ts:271
The world's difficulty setting.
Returns
"peaceful" | "easy" | "normal" | "hard"
scale()
scale():
number
Defined in: loot/src/dialect.ts:277
Bedrock's regional difficulty as a factor between 0 and 1, which scales the max_chance of random_regional_difficulty_chance. A region at 1 rolls the table's stated chance, and a region at 0 rolls nothing.
Returns
number
LootEntry
Defined in: loot/src/model.ts:48
One candidate a pool can draw, after the container holding it passed its condition.
Methods
produce()
produce(
emit,evaluation):void
Defined in: loot/src/model.ts:52
Produces this candidate's stacks, already carrying every modifier on the way out.
Parameters
emit
evaluation
Returns
void
weight()
weight(
luck):number
Defined in: loot/src/model.ts:50
Java's weight + quality * luck, floored to an integer and clamped at zero.
Parameters
luck
number
Returns
number
LootEvaluation
Defined in: loot/src/model.ts:39
What one roll carries beyond the predicate context: Java's luck, and the two seams the entry grammar needs. Both seams are optional, and an entry that reaches a missing one reports a diagnostic and produces nothing.
Properties
context
readonlycontext:PredicateContext
Defined in: loot/src/model.ts:40
dynamic?
readonlyoptionaldynamic?:DynamicDropSource
Defined in: loot/src/model.ts:43
luck
readonlyluck:number
Defined in: loot/src/model.ts:42
Java's luck, which scales an entry's quality into its weight.
slots?
readonlyoptionalslots?:SlotSourceView
Defined in: loot/src/model.ts:44
LootFinding
Defined in: loot/src/registry.ts:92
One finding, with the table that was being compiled when it was reported.
A Diagnostic carries a path inside one file and no file, because the grammar parses files it is handed. The registry is what knows which file, so it is what says: a host restating these in its own report needs the id to find the pack and the path on disk.
Extends
Properties
id
readonlyid:string
Defined in: loot/src/registry.ts:94
The registered id of the table, or the empty string for a finding that belongs to no one table.
message
readonlymessage:string
Defined in: predicates/src/diagnostics.ts:9
Inherited from
path
readonlypath:string
Defined in: predicates/src/diagnostics.ts:8
Dotted path to the offending JSON member, for example terms[1].predicate.
Inherited from
severity
readonlyseverity:DiagnosticSeverity
Defined in: predicates/src/diagnostics.ts:6
Inherited from
LootGrammar
Defined in: loot/src/table.ts:90
What the table grammar carries down the parse beside the ParseContext.
Properties
dialect
readonlydialect:"java"|"bedrock"
Defined in: loot/src/table.ts:92
Which edition's spelling the file uses.
difficulty
readonlydifficulty:LootDifficultyView
Defined in: loot/src/table.ts:94
What Bedrock's two difficulty-scaled conditions read.
LootKeySet
Defined in: loot/src/dialect.ts:23
What one level of one dialect's grammar does with the keys it meets.
Properties
read
readonlyread: readonlystring[]
Defined in: loot/src/dialect.ts:25
Keys the parser acts on.
skipped?
readonlyoptionalskipped?:Readonly<Record<string,string>>
Defined in: loot/src/dialect.ts:31
Keys the dialect defines that this package reads no further, each naming what goes unapplied. These report a warning rather than an error, because what they change about a result is known and bounded.
LootMappingLoss
Defined in: loot/src/mapping.ts:50
One translation a caller should know about.
Properties
bedrockIdentifier?
readonlyoptionalbedrockIdentifier?:string
Defined in: loot/src/mapping.ts:57
javaId
readonlyjavaId:string
Defined in: loot/src/mapping.ts:51
kind
readonlykind:"fallback"|"unknown"
Defined in: loot/src/mapping.ts:56
fallback kept a reviewed substitute item; unknown had no Bedrock item at all and the stack was dropped.
reason
readonlyreason:string
Defined in: loot/src/mapping.ts:58
reference?
readonlyoptionalreference?:string
Defined in: loot/src/mapping.ts:60
Where the reviewed loss is documented. Absent for an unknown identifier.
LootPackDefinitions
Defined in: loot/src/packs.ts:69
The registries of a loaded pack stack this package reads.
Every member but LootPackDefinitions.lootTables is structural, so a host spreads Definitions from @jsprismarine/packs in and overrides that one member with the source it means.
Properties
itemModifiers?
readonlyoptionalitemModifiers?:ReadonlyMap<string,unknown>
Defined in: loot/src/packs.ts:73
lootTables
readonlylootTables:LootTableSource
Defined in: loot/src/packs.ts:71
The tables to roll, with the dialect they are written in.
predicates?
readonlyoptionalpredicates?:ReadonlyMap<string,unknown>
Defined in: loot/src/packs.ts:72
recipesJava?
readonlyoptionalrecipesJava?:ReadonlyMap<string,unknown>
Defined in: loot/src/packs.ts:74
tags?
readonlyoptionaltags?:ReadonlyMap<string,unknown>
Defined in: loot/src/packs.ts:76
Tags keyed the way the loader keys them, with the tagged registry first: item/minecraft:planks.
LootParseOptions
Defined in: loot/src/table.ts:101
Everything parseLootTable can be told, plus the id the table is registered under.
Extends
Properties
diagnostics?
optionaldiagnostics?:DiagnosticCollector
Defined in: predicates/src/parse.ts:35
Reuse a collector to gather diagnostics from several parses into one report.
Inherited from
dialect?
optionaldialect?:"java"|"bedrock"
Defined in: loot/src/table.ts:112
Which edition's spelling the file uses. Defaults to java, which is the grammar the 1447 vanilla datapack tables are written in.
difficulty?
optionaldifficulty?:LootDifficultyView
Defined in: loot/src/table.ts:114
What Bedrock's two difficulty-scaled conditions read. Defaults to DEFAULT_DIFFICULTY.
extensions?
optionalextensions?:GrammarExtensions
Defined in: predicates/src/parse.ts:38
Inherited from
id?
optionalid?:string
Defined in: loot/src/table.ts:107
The namespaced id this table is registered under. Setting it makes a reference that leads back here report a cycle instead of expanding the table one more time.
path?
optionalpath?:string
Defined in: predicates/src/parse.ts:37
Prefix for diagnostic paths, such as the file the JSON came from.
Inherited from
resolver?
optionalresolver?:ReferenceResolver
Defined in: predicates/src/parse.ts:33
Resolves namespaced ids and #tag references; without it a reference reports an error.
Inherited from
strict?
optionalstrict?:boolean
Defined in: loot/src/table.ts:121
Throw instead of returning a table that reported an error. This is the one exception to the package's rule that parsing never throws, and it exists so a host can refuse to run on a table it cannot evaluate rather than roll a gate it failed to read.
LootPool
Defined in: loot/src/model.ts:65
One compiled pools member.
Properties
bonusRolls
readonlybonusRolls:NumberProvider
Defined in: loot/src/model.ts:71
Extra rolls per point of luck, floored after the multiplication as Java does.
condition
readonlycondition:Predicate
Defined in: loot/src/model.ts:66
entries
readonlyentries: readonlyLootEntryContainer[]
Defined in: loot/src/model.ts:72
modifier
readonlymodifier:ItemModifier
Defined in: loot/src/model.ts:68
Applied to every stack the pool produces, after the entry's own modifier.
rolls
readonlyrolls:NumberProvider
Defined in: loot/src/model.ts:69
tiers?
readonlyoptionaltiers?:LootTiers
Defined in: loot/src/model.ts:77
Bedrock's ladder draw, which replaces the weighted one. Absent on every Java pool, because Java has no such member.
LootRandomState
Defined in: loot/src/random.ts:34
JSON-safe state for one Java Xoroshiro128++ loot stream.
Properties
algorithm
readonlyalgorithm:"xoroshiro128++"
Defined in: loot/src/random.ts:36
hi
readonlyhi:string
Defined in: loot/src/random.ts:38
lo
readonlylo:string
Defined in: loot/src/random.ts:37
version
readonlyversion:1
Defined in: loot/src/random.ts:35
LootRegistryOptions
Defined in: loot/src/registry.ts:28
Everything a LootRegistry needs beyond the pack stack itself.
Properties
content?
readonlyoptionalcontent?:LootContentOptions
Defined in: loot/src/registry.ts:36
What the content view needs; the registry passes it to every context it builds. Each member the host leaves out that the pack stack can answer is filled in from the stack: see LootRegistry.
difficulty?
readonlyoptionaldifficulty?:LootDifficultyView
Defined in: loot/src/registry.ts:56
What Bedrock's two difficulty-scaled conditions read.
enchantments?
readonlyoptionalenchantments?: (random) =>EnchantmentView
Defined in: loot/src/registry.ts:46
The enchantment facts enchant_randomly, enchant_with_levels, apply_bonus and table_bonus read.
A factory rather than a view, because the enchanting table draw enchant_with_levels runs has to come out of the same stream as the rest of the roll. The registry calls it with the stream the table drew from, so a seeded roll enchants the same way twice.
Parameters
random
Returns
extensions?
readonlyoptionalextensions?:GrammarExtensions
Defined in: loot/src/registry.ts:54
Entity sub-predicate and data component predicate types this host adds to the grammar.
items?
readonlyoptionalitems?:ItemStackOps
Defined in: loot/src/registry.ts:52
The per-item limits set_count, limit_count and the final stack split read. Without it every item stacks to 64, so a roll of 20 ender pearls arrives as one stack instead of the two Bedrock shows.
strict?
readonlyoptionalstrict?:boolean
Defined in: loot/src/registry.ts:62
Refuse a table that reported an error instead of rolling what is left of it. LootRegistry.table and LootRegistry.validate throw a LootGrammarError when a table fails to compile cleanly.
worldSeed?
readonlyoptionalworldSeed?:bigint
Defined in: loot/src/registry.ts:30
The world seed that keys every table's random_sequence. Defaults to 0.
LootRollRequest
Defined in: loot/src/registry.ts:66
What one roll through the registry can be told.
Extends
Omit<LootContextOptions,"content">
Properties
diagnostics?
optionaldiagnostics?:DiagnosticCollector
Defined in: predicates/src/context.ts:126
Defaults to a fresh collector, reachable as PredicateContext.diagnostics.
Inherited from
Omit.diagnostics
dynamic?
readonlyoptionaldynamic?:DynamicDropSource
Defined in: loot/src/registry.ts:72
enchantments?
optionalenchantments?:EnchantmentView
Defined in: predicates/src/context.ts:128
Inherited from
Omit.enchantments
items?
optionalitems?:ItemStackOps
Defined in: predicates/src/context.ts:127
Inherited from
Omit.items
level?
optionallevel?:LevelView
Defined in: predicates/src/context.ts:124
Inherited from
Omit.level
luck?
readonlyoptionalluck?:number
Defined in: loot/src/content.ts:209
Java's luck, used by the nested rolls set_contents makes. Pass the same value to the roll, or let LootRegistry pass both for you.
Inherited from
parameters?
optionalparameters?:LootContextParameters
Defined in: predicates/src/context.ts:121
Inherited from
Omit.parameters
parameterSet?
optionalparameterSet?:"chest"|"empty"|"generic"|"command"|"command_slot_source"|"command_compute_default"|"command_compute_position"|"command_compute_entity"|"selector"|"villager_trade"|"fishing"|"entity"|"equipment"|"archaeology"|"gift"|"barter"|"vault"|"advancement_reward"|"advancement_entity"|"advancement_location"|"block_use"|"block"|"shearing"|"entity_interact"|"block_interact"|"container_process"|"enchanted_damage"|"enchanted_item"|"enchanted_location"|"enchanted_entity"|"hit_block"
Defined in: predicates/src/context.ts:120
Defaults to empty, which declares no parameters and so reports every read.
Inherited from
Omit.parameterSet
random?
readonlyoptionalrandom?:RandomSource
Defined in: loot/src/registry.ts:78
Replaces the table's own sequenced stream, for a test that wants a scripted draw.
Overrides
Omit.random
slots?
readonlyoptionalslots?:SlotSourceView
Defined in: loot/src/registry.ts:73
split?
readonlyoptionalsplit?:boolean
Defined in: loot/src/registry.ts:71
Split each result down to the item's maximum stack size, which is what Java's public roll does. Defaults to true.
LootSequencesState
Defined in: loot/src/random.ts:45
JSON-safe state for the unkeyed stream and all named loot sequences.
Properties
streams
readonlystreams: readonlyLootSequenceEntryState[]
Defined in: loot/src/random.ts:49
unkeyed
readonlyunkeyed:LootRandomState
Defined in: loot/src/random.ts:48
version
readonlyversion:1
Defined in: loot/src/random.ts:46
worldSeed
readonlyworldSeed:string
Defined in: loot/src/random.ts:47
LootTable
Defined in: loot/src/model.ts:81
A compiled loot table, ready to roll.
Properties
modifier
readonlymodifier:ItemModifier
Defined in: loot/src/model.ts:88
Applied to every stack the table produces, last of the three modifier levels.
parameterSet
readonlyparameterSet:"chest"|"empty"|"generic"|"command"|"command_slot_source"|"command_compute_default"|"command_compute_position"|"command_compute_entity"|"selector"|"villager_trade"|"fishing"|"entity"|"equipment"|"archaeology"|"gift"|"barter"|"vault"|"advancement_reward"|"advancement_entity"|"advancement_location"|"block_use"|"block"|"shearing"|"entity_interact"|"block_interact"|"container_process"|"enchanted_damage"|"enchanted_item"|"enchanted_location"|"enchanted_entity"|"hit_block"
Defined in: loot/src/model.ts:83
The context key set the type field names, generic when it names none.
pools
readonlypools: readonlyLootPool[]
Defined in: loot/src/model.ts:86
randomSequence
readonlyrandomSequence:string|undefined
Defined in: loot/src/model.ts:85
The random_sequence id, which keys the table's stream for a world seed.
references
readonlyreferences: readonlystring[]
Defined in: loot/src/model.ts:90
Ids of the loot tables this table names by reference, for the registry's cycle report.
LootTableSource
Defined in: loot/src/packs.ts:34
A map of loot tables and the edition whose grammar its files are written in.
Build one with javaLootTables or bedrockLootTables; there is no third way to make one, which is the point.
Type Parameters
Dialect
Dialect extends LootDialect = LootDialect
Narrowed by the two builders, so a caller that needs Java tables specifically can say LootTableSource<'java'> and have a Bedrock source refuse to compile.
Properties
dialect
readonlydialect:Dialect
Defined in: loot/src/packs.ts:36
Which edition's spelling the tables are written in.
tables
readonlytables:ReadonlyMap<string,unknown>
Defined in: loot/src/packs.ts:38
The tables, keyed by the id the pack stack registered them under.
LootTiers
Defined in: loot/src/dialect.ts:482
Bedrock's tiers: a pool that draws a rung of a ladder rather than a weighted candidate.
It reproduces Java's Mob.populateArmor, which is why zombie_equipment states an initial range of 3 over six armor sets with three bonus rolls at 0.1087. Leather, copper and gold are common, and diamond needs all three bonuses to land.
Properties
bonusChance
readonlybonusChance:number
Defined in: loot/src/dialect.ts:488
The chance each bonus roll climbs.
bonusRolls
readonlybonusRolls:number
Defined in: loot/src/dialect.ts:486
How many chances the draw gets to climb one rung.
initialRange
readonlyinitialRange:number
Defined in: loot/src/dialect.ts:484
How many entries the opening draw may land on, counted from the first.
MappedLoot
Defined in: loot/src/mapping.ts:64
A translated roll: the stacks a Bedrock client can be sent, and everything that did not survive.
Properties
losses
readonlylosses: readonlyLootMappingLoss[]
Defined in: loot/src/mapping.ts:67
One entry per affected stack, in the order the roll produced them. Never silently empty.
stacks
readonlystacks: readonlyBedrockStack[]
Defined in: loot/src/mapping.ts:65
RollOptions
Defined in: loot/src/table.ts:77
What a parsed table does with the stacks it drew.
Properties
dynamic?
readonlyoptionaldynamic?:DynamicDropSource
Defined in: loot/src/table.ts:85
luck?
readonlyoptionalluck?:number
Defined in: loot/src/table.ts:79
Java's luck, which scales each entry's quality into its weight. Defaults to 0.
slots?
readonlyoptionalslots?:SlotSourceView
Defined in: loot/src/table.ts:86
split?
readonlyoptionalsplit?:boolean
Defined in: loot/src/table.ts:84
Split each result down to the item's maximum stack size, which is what Java's public roll does and its raw roll does not. Defaults to true.
StatefulLootRandomSource
Defined in: loot/src/random.ts:53
A loot random source that can continue from a JSON-safe state.
Extends
Methods
nextFloat()
nextFloat():
number
Defined in: predicates/src/random.ts:8
Returns a float in the half-open interval [0, 1).
Returns
number
Inherited from
nextInt()
nextInt(
bound):number
Defined in: predicates/src/random.ts:10
Returns an integer in the half-open interval [0, bound).
Parameters
bound
number
Returns
number
Inherited from
restoreState()
restoreState(
state):void
Defined in: loot/src/random.ts:57
Restores this stream from a state produced by lootSequenceRandom.
Parameters
state
unknown
Returns
void
saveState()
saveState():
LootRandomState
Defined in: loot/src/random.ts:55
Returns the state needed to continue this exact stream.
Returns
Type Aliases
BedrockDifficulty
BedrockDifficulty = typeof
BEDROCK_DIFFICULTIES[number]
Defined in: loot/src/dialect.ts:260
One of BEDROCK_DIFFICULTIES.
DynamicDropSource
DynamicDropSource = (
name,context) => readonlyItemStack[] |undefined
Defined in: loot/src/model.ts:25
Answers a dynamic entry. Java calls these dynamic drops and uses them for the contents a block entity carries into its own drop, such as a shulker box's inventory or a banner's patterns.
Parameters
name
string
context
Returns
readonly ItemStack[] | undefined
ItemIdentifierMapper
ItemIdentifierMapper = (
javaId) =>ItemMappingOutcome
Defined in: loot/src/mapping.ts:33
Maps one Java item identifier to Bedrock. Never returns undefined.
Parameters
javaId
string
Returns
ItemMappingOutcome
ItemMappingOutcome = {
bedrock:BedrockItemReference;kind:"mapped"|"passthrough"; } | {bedrock:BedrockItemReference;kind:"loss";loss: {reason:string;reference:string; }; } | {javaId:string;kind:"unknown"; }
Defined in: loot/src/mapping.ts:20
What a Java item identifier lookup produced.
Union Members
Type Literal
{ bedrock: BedrockItemReference; kind: "mapped" | "passthrough"; }
A Bedrock item, either a clean mapping or a non-minecraft: identifier passed through.
Type Literal
{ bedrock: BedrockItemReference; kind: "loss"; loss: { reason: string; reference: string; }; }
A reviewed loss: the Java item's identity does not survive, and bedrock is its listed fallback.
Type Literal
{ javaId: string; kind: "unknown"; }
Not an item of the pinned Java version.
LootDialect
LootDialect = typeof
LOOT_DIALECTS[number]
Defined in: loot/src/dialect.ts:20
Which edition's spelling a table is written in.
LootEntryContainer
LootEntryContainer = (
emit,evaluation) =>boolean
Defined in: loot/src/model.ts:62
A compiled entry container. It gates on its own condition, then offers its candidates to emit.
Parameters
emit
(entry) => void
evaluation
Returns
boolean
Whether the container contributed, which is what alternatives and sequence branch on.
LootEntryType
LootEntryType = typeof
LOOT_ENTRY_TYPES[number]
Defined in: loot/src/table.ts:74
One of LOOT_ENTRY_TYPES.
LootSequenceEntryState
LootSequenceEntryState = readonly [
sequence:string,state:LootRandomState]
Defined in: loot/src/random.ts:42
One loot sequence ID and the state of its stream.
LootTableCycle
LootTableCycle = readonly
string[]
Defined in: loot/src/registry.ts:82
One reference cycle, as the chain that closes it.
SlotSourceView
SlotSourceView = (
source,context) => readonlyItemStack[] |undefined
Defined in: loot/src/model.ts:32
Answers a slots entry. The slot_source registry has six types and no vanilla files, and a slot model belongs to the container code rather than here, so this package hands the parsed JSON over and takes the stacks back.
Parameters
source
unknown
context
Returns
readonly ItemStack[] | undefined
StackSink
StackSink = (
stack) =>void
Defined in: loot/src/model.ts:18
Receives each stack a roll produces, in the order the pools produce it.
Parameters
stack
Returns
void
StructureLocator
StructureLocator = (
request,context) =>Vec3|undefined
Defined in: loot/src/content.ts:33
Finds the structure an exploration_map asks for, or nothing when the search comes up empty.
Parameters
request
context
Returns
Vec3 | undefined
Variables
BEDROCK_DIFFICULTIES
constBEDROCK_DIFFICULTIES: readonly ["peaceful","easy","normal","hard"]
Defined in: loot/src/dialect.ts:257
Bedrock's four difficulty settings, which random_difficulty_chance names a chance for.
BEDROCK_IMPLEMENTED_FUNCTIONS
constBEDROCK_IMPLEMENTED_FUNCTIONS:object
Defined in: loot/src/dialect.ts:185
Bedrock loot functions this package applies while compiling an entry.
Type Declaration
set_count
readonlyset_count:"sets the entry's stack count using Bedrock's range"="sets the entry's stack count using Bedrock's range"
set_data_from_color_index
readonlyset_data_from_color_index:"copies the entity color into Bedrock auxiliary item data"='copies the entity color into Bedrock auxiliary item data'
BEDROCK_REVIEWED_CONDITIONS
constBEDROCK_REVIEWED_CONDITIONS:object
Defined in: loot/src/dialect.ts:375
The Bedrock loot conditions this package does not evaluate, each naming what it reads.
All twelve want the same two things and this package has neither for a Bedrock roll: the entity the table is being rolled for, and the world around it. A roll here carries a random source and a parameter set, so there is no killer to ask about, no variant to read off a mob and no biome under it.
Being on this list changes the report, not the roll: the gate still closes, because a condition nothing evaluates must not pass. It drops from an error to a warning for the reason reportUnreadKeys already applies to keys — what is lost is known and bounded, which is the whole difference between a reviewed gap and an unreviewed one. An unlisted condition stays an error.
None of the twelve appear in the 18 equipment tables, which are the only Bedrock tables this server rolls. All 79 uses are on entity death drops and chest tables, and the server draws both from the Java registry.
Type Declaration
biome_has_tag
readonlybiome_has_tag:"a tag on the biome the roll happens in"='a tag on the biome the roll happens in'
bool_property
readonlybool_property:"an entity property a behavior pack declared"='an entity property a behavior pack declared'
damaged_by_entity
readonlydamaged_by_entity:"which entity type dealt the last damage"='which entity type dealt the last damage'
entity_killed
readonlyentity_killed:"a predicate over the entity that was killed"='a predicate over the entity that was killed'
has_mark_variant
readonlyhas_mark_variant:"the entity's minecraft:mark_variant"="the entity's minecraft:mark_variant"
has_variant
readonlyhas_variant:"the entity's minecraft:variant"="the entity's minecraft:variant"
is_baby
readonlyis_baby:"the entity's age"="the entity's age"
killed_by_entity
readonlykilled_by_entity:"which entity type landed the killing blow"='which entity type landed the killing blow'
killed_by_player
readonlykilled_by_player:"whether a player landed the killing blow"='whether a player landed the killing blow'
killed_by_player_or_pets
readonlykilled_by_player_or_pets:"whether a player or a tamed pet of one landed the killing blow"='whether a player or a tamed pet of one landed the killing blow'
passenger_of_entity
readonlypassenger_of_entity:"what the entity is riding"='what the entity is riding'
random_chance_with_looting
readonlyrandom_chance_with_looting:"a chance scaled by the killer's looting level"="a chance scaled by the killer's looting level"
BEDROCK_REVIEWED_FUNCTIONS
constBEDROCK_REVIEWED_FUNCTIONS:object
Defined in: loot/src/dialect.ts:164
The Bedrock loot functions this package reads and does not apply, each naming what a result comes out as without it.
Nineteen of them, and only three reach anything the server rolls today: enchant_random_gear and looting_enchant on the equipment tables, and set_banner_details on the raid captains. So a skeleton's bow arrives unenchanted and a pillager captain's banner is a plain white one. The other sixteen are on chest, fishing and death-drop tables, which the server draws from the Java registry, where the same work is already done by @jsprismarine/predicates.
A listed function warns and is skipped. An unlisted one is an error, for the reason reportUnreadKeys gives: a reviewed gap has a known effect and an unreviewed one has an unknown effect, and a new Bedrock function should reach someone rather than quietly change what a table produces.
Type Declaration
enchant_book_for_trading
readonlyenchant_book_for_trading:"a villager's trade book arrives blank"="a villager's trade book arrives blank"
enchant_random_gear
readonlyenchant_random_gear:"a mob's gear arrives unenchanted"="a mob's gear arrives unenchanted"
enchant_randomly
readonlyenchant_randomly:"the result arrives unenchanted"='the result arrives unenchanted'
enchant_with_levels
readonlyenchant_with_levels:"the result arrives unenchanted"='the result arrives unenchanted'
exploration_map
readonlyexploration_map:"a rolled map points nowhere"='a rolled map points nowhere'
explosion_decay
readonlyexplosion_decay:"a nearby explosion destroys none of the drop"='a nearby explosion destroys none of the drop'
furnace_smelt
readonlyfurnace_smelt:"a burning mob drops its loot raw"='a burning mob drops its loot raw'
looting_enchant
readonlylooting_enchant:"a killer's looting level adds nothing"="a killer's looting level adds nothing"
random_aux_value
readonlyrandom_aux_value:"the aux value stays at zero"='the aux value stays at zero'
set_armor_trim
readonlyset_armor_trim:"a rolled piece arrives untrimmed"='a rolled piece arrives untrimmed'
set_banner_details
readonlyset_banner_details:"a raid captain's banner is a plain one"="a raid captain's banner is a plain one"
set_damage
readonlyset_damage:"a rolled tool arrives undamaged"='a rolled tool arrives undamaged'
set_data
readonlyset_data:"a variant such as a dye color comes out as the default"='a variant such as a dye color comes out as the default'
set_ominous_bottle_amplifier
readonlyset_ominous_bottle_amplifier:"the bottle carries the lowest bad omen"='the bottle carries the lowest bad omen'
set_potion
readonlyset_potion:"a rolled bottle holds water"='a rolled bottle holds water'
set_stew_effect
readonlyset_stew_effect:"a suspicious stew carries no effect"='a suspicious stew carries no effect'
specific_enchants
readonlyspecific_enchants:"the named enchantments are missing"='the named enchantments are missing'
DEFAULT_DIFFICULTY
constDEFAULT_DIFFICULTY:LootDifficultyView
Defined in: loot/src/dialect.ts:289
The difficulty a roll sees when the host binds none: normal, in a fully ramped region.
A scale of 1 makes a table's stated max_chance its actual chance, so zombie_equipment.json arms one zombie in twenty from its 0.05. The other end of the range, a fresh region at 0, would arm none at all and read as the same silent failure this module exists to stop.
DYE_COLORS
constDYE_COLORS: readonly [16383998,16351261,13061821,3847130,16701501,8439583,15961002,4673362,10329495,1481884,8991416,3949738,8606770,6192150,11546150,1908001]
Defined in: loot/src/content.ts:27
The 16 DyeColor.textureDiffuseColor values of Java 26.3, in registry order, which is the palette set_random_dyes draws from.
LOOT_DIALECTS
constLOOT_DIALECTS: readonly ["java","bedrock"]
Defined in: loot/src/dialect.ts:17
The spellings LootDialect covers.
LOOT_ENTRY_TYPES
constLOOT_ENTRY_TYPES: readonly ["empty","item","loot_table","dynamic","tag","slots","alternatives","sequence","group"]
Defined in: loot/src/table.ts:61
The nine loot_pool_entry_type members Java 26.3 registers.
Functions
bedrockLootTables()
bedrockLootTables(
tables):LootTableSource<"bedrock">
Defined in: loot/src/packs.ts:57
A behavior pack's loot tables, in Bedrock's spelling.
Parameters
tables
ReadonlyMap<string, unknown>
Definitions.lootTables from @jsprismarine/packs, keyed by the pack-relative path a minecraft:equipment component names, such as loot_tables/entities/zombie_equipment.json.
Returns
LootTableSource<"bedrock">
bedrockRange()
bedrockRange(
value):unknown
Defined in: loot/src/dialect.ts:251
Rewrites Bedrock's untyped range into the provider Java spells out.
Bedrock writes a range as { "min": 2, "max": 4 } where Java writes { "type": "minecraft:uniform", "min": 2, "max": 4 }, and the two mean the same draw. Naming the type the shared provider grammar already implements is the whole translation, so a Bedrock rolls and a Java one are one implementation rather than two that have to be kept agreeing.
Anything else passes through untouched, including an object that does name a type, so a Bedrock table using Java's spelling still parses.
Parameters
value
unknown
A rolls, bonus_rolls or count member.
Returns
unknown
createLootContext()
createLootContext(
options?):PredicateContext
Defined in: loot/src/content.ts:218
Builds a predicate context with this package's content view already wired in, which is the only way to close the loop set_contents needs: rolling its nested entries takes the very context whose content view is being built.
Parameters
options?
LootContextOptions = {}
Returns
createPackResolver()
createPackResolver(
definitions):ReferenceResolver
Defined in: loot/src/packs.ts:120
Builds the reference resolver the grammar needs from a loaded pack stack, so a loot table may name a predicate, an item modifier or another loot table by id or by tag.
Parameters
definitions
Returns
gateAt()
gateAt(
value,context,dialect,difficulty):Predicate
Defined in: loot/src/dialect.ts:449
Compiles a condition field so that a condition the grammar cannot read refuses instead of passing.
Java folds a composed condition field with and, and a term it fails to compile drops out of the fold, which leaves the remaining terms deciding a gate the author wrote more conditions for. For loot that is the wrong direction to fail in, so any error raised while compiling the field closes the gate for good. The error itself is already in the collector, which is what makes the refusal explainable rather than mysterious.
Parameters
value
unknown
The condition or conditions member, absent when the level carries no gate.
context
dialect
"java" | "bedrock"
difficulty
Returns
A predicate that passes only when every term the author wrote was both read and met.
javaLootTables()
javaLootTables(
tables):LootTableSource<"java">
Defined in: loot/src/packs.ts:46
A datapack's loot tables, in Java's spelling.
Parameters
tables
ReadonlyMap<string, unknown>
Definitions.lootTablesJava from @jsprismarine/packs, or any map keyed by namespaced id.
Returns
LootTableSource<"java">
lootSequenceRandom()
lootSequenceRandom(
worldSeed,sequence?):StatefulLootRandomSource
Defined in: loot/src/random.ts:190
Builds the stream a loot table draws from, the way Java's RandomSequence does: upgrade the world seed to 128 bits, exclusive-or the MD5 hash of the sequence id over it when the table names one, then mix both halves.
Parameters
worldSeed
bigint
The world seed as a signed 64-bit value.
sequence?
string
The table's random_sequence id. Omitting it gives the stream RandomSource.create(worldSeed) produces, which is what Java falls back to for a table that names no sequence.
Returns
lootTableReferences()
lootTableReferences(
value,dialect?): readonlystring[]
Defined in: loot/src/table.ts:640
Collects the loot tables a table names by id, walking the raw JSON rather than the compiled closures. The registry turns these into the edges of its reference graph, which is how it reports a cycle without compiling anything.
Parameters
value
unknown
dialect?
"java" | "bedrock" = 'java'
Returns
readonly string[]
mapLootToBedrock()
mapLootToBedrock(
stacks,mapper):MappedLoot
Defined in: loot/src/mapping.ts:77
Translates a rolled result into Bedrock items.
A reviewed loss keeps its fallback item and reports; an identifier the pinned Java version does not have is dropped and reports. Nothing is dropped without an entry in losses.
Parameters
stacks
readonly ItemStack[]
mapper
Returns
packJson()
packJson(
entry):unknown
Defined in: loot/src/packs.ts:85
Reads the JSON out of one pack registry entry. The loader wraps each file in a record carrying its pack and path, so an object with a data member is that record and anything else is the parsed file itself. No Java file this package reads has a top-level data key, so the two never collide.
Parameters
entry
unknown
Returns
unknown
parseLootEntries()
parseLootEntries(
value,options?):ParseResult<readonlyLootEntryContainer[]>
Defined in: loot/src/table.ts:550
Compiles a bare list of entry containers, which is the entries field a set_contents modifier carries. It is the only place the entry grammar appears outside a pool.
Parameters
value
unknown
options?
ParseOptions & Pick<LootParseOptions, "dialect" | "difficulty"> = {}
Returns
ParseResult<readonly LootEntryContainer[]>
parseLootTable()
parseLootTable(
value,options?):ParseResult<LootTable>
Defined in: loot/src/table.ts:709
Compiles one loot table file. Parsing never throws unless LootParseOptions.strict says so: every fault lands in the returned diagnostics and the table rolls to whatever is still well formed.
Parameters
value
unknown
options?
LootParseOptions = {}
Returns
Throws
In strict mode, when the table reported an error.
produceEntries()
produceEntries(
containers,evaluation): readonlyItemStack[]
Defined in: loot/src/table.ts:564
Produces every stack a bare entry list offers. Unlike a pool, nothing is weighed or drawn: Java's set_contents takes all of them.
Parameters
containers
readonly LootEntryContainer[]
evaluation
Returns
readonly ItemStack[]
reportBedrockFunctions()
reportBedrockFunctions(
value,context):void
Defined in: loot/src/dialect.ts:202
Reports each member of a Bedrock entry's functions array against BEDROCK_REVIEWED_FUNCTIONS, so the gap reads as which functions went unapplied rather than as a count of entries that had some.
Parameters
value
unknown
The functions member, absent when the entry carries none.
context
The parse context at functions.
Returns
void
reportEntryKeys()
reportEntryKeys(
value,context,dialect,type):void
Defined in: loot/src/dialect.ts:131
Reports the keys of one entry that the dialect's entry grammar does not read, against the union of what every entry may carry and what its own type adds.
Parameters
value
context
dialect
"java" | "bedrock"
type
string
The entry's type, without the namespace.
Returns
void
reportPoolKeys()
reportPoolKeys(
value,context,dialect):void
Defined in: loot/src/dialect.ts:122
Reports the keys of a pool that the dialect's pool grammar does not read.
Parameters
value
context
dialect
"java" | "bedrock"
Returns
void
reportTableKeys()
reportTableKeys(
value,context,dialect):void
Defined in: loot/src/dialect.ts:118
Reports the keys of a table that the dialect's table grammar does not read.
Parameters
value
context
dialect
"java" | "bedrock"
Returns
void
reportUnreadKeys()
reportUnreadKeys(
value,keys,context,dialect,level):void
Defined in: loot/src/dialect.ts:48
Reports every key at one level that nothing in the grammar reads.
This is the whole of what stops the next dialect mismatch. A key the parser has no case for changes the file's meaning and not the roll, and a conditions array sitting unread beside a pool is indistinguishable from a pool with no gate at all. An unknown key is an error because its effect is unknown. A key this package names and leaves alone is a warning, because its effect is not.
Parameters
value
The JSON object at this level.
keys
What the level's parser reads and knowingly skips.
context
dialect
"java" | "bedrock"
level
string
How the level is named in the report, such as pool or item entry.
Returns
void
rollInto()
rollInto(
table,evaluation,emit):void
Defined in: loot/src/table.ts:795
Java's LootTable.getRandomItemsRaw: every pool, through the table modifier, unsplit.
Parameters
table
evaluation
emit
Returns
void
rollLootTable()
rollLootTable(
table,context,options?): readonlyItemStack[]
Defined in: loot/src/table.ts:825
Rolls a table once, in Java's order: every pool in turn, the rolled number of draws each, one weighted candidate per draw, and each stack through the entry modifier, then the pool modifier, then the table modifier.
The randomness is the context's, so a seeded source reproduces the draw. Use lootSequenceRandom to build the stream Java's random_sequence gives this table for a world seed.
Parameters
table
context
options?
RollOptions = {}
Returns
readonly ItemStack[]
tableAt()
tableAt(
value,context,grammar?):LootTable
Defined in: loot/src/table.ts:673
Compiles a loot table from parsed JSON at a point in an enclosing parse.
Parameters
value
unknown
context
grammar?
LootGrammar = JAVA_GRAMMAR
Returns
tiersAt()
tiersAt(
value,context):LootTiers|undefined
Defined in: loot/src/dialect.ts:499
Compiles a pool's tiers member.
Parameters
value
unknown
context
Returns
LootTiers | undefined
The ladder, or undefined for a pool that has none and so draws by weight.