API reference / @jsprismarine/predicates
@jsprismarine/predicates
The Java Edition predicate, item modifier and value provider evaluator. Loot tables, advancements and enchantments all compile their conditions and functions through this package. It parses Mojang's JSON once into closures and evaluates them against a PredicateContext that carries the loot context parameters, an injected random source, and the views a host plugs its own registries into.
Every grammar member here was read out of the Java 26.3 server jar rather than from a wiki page. Parsing never throws: faults land in a DiagnosticCollector as errors or warnings, and the evaluation gives the safe answer instead.
Install
pnpm add @jsprismarine/predicatesUsing it
import { PredicateContext, parsePredicate } from '@jsprismarine/predicates';
const { value: survivesExplosion, diagnostics } = parsePredicate({ type: 'minecraft:survives_explosion' });
const context = new PredicateContext({
parameterSet: 'block',
parameters: { block_state: { name: 'minecraft:stone' }, origin: { x: 0, y: 64, z: 0 }, explosion_radius: 4 }
});
survivesExplosion(context);
context.diagnostics.entries;parseItemModifier, parseIntProvider, parseFloatProvider and parseLevelBasedValue follow the same shape: they return the compiled value together with the diagnostics from parsing it.
Grammar coverage
| Registry | 26.3 registers | This package |
|---|---|---|
loot_condition_type | 20 | 20 |
loot_function_type | 42 | 42 |
context_int_provider_type | 23 | 23 |
context_float_provider_type | 28 | 28 |
enchantment_level_based_value_type | 6 plus the bare-number constant | 7 |
loot_score_provider_type | 2 | 2 |
loot_nbt_provider_type | 2 | 1, storage reported |
entity_sub_predicate_type | 25 | 23, with nbt and slots reported |
data_component_predicate_type | 15 | 4 typed, the rest reported, plus the presence fallback |
Three names in the original brief for this package do not exist in 26.3, and the table above follows the jar. block_state_property is now match_block and carries the block predicate inline. value_check split into int_value_check and float_value_check. reference was removed when every field learned to take a bare id, which is the composition rule below. The jar also adds environment_attribute_check, which the brief did not list.
The entity sub-predicates implemented are the 14 vanilla's own loot tables and advancements use (entity_type, location, components, type_specific/sheep, equipment, flags, vehicle, distance, type_specific/player, type_specific/cube_mob, type_specific/fishing_hook, type_specific/raider, type_specific/lightning, stepping_on) plus entity_tags, movement, movement_affected_by, effects, periodic_tick, team, passenger, targeted_entity and predicates. nbt and slots need an NBT matcher and a slot model that live elsewhere, so they warn and evaluate false.
The composition rule
26.3 made every field of a composable type accept four forms: an inline value, a namespaced id, a list mixing both, and a hash-prefixed tag id. One helper, parseComposed, implements it for all eight composable registries, and every predicate, modifier and provider field in this package goes through it.
{ "condition": "minecraft:tool/can_silk_touch" }
{ "condition": [{ "type": "minecraft:survives_explosion" }, "minecraft:tool/can_shear"] }
{ "modifier": [{ "type": "minecraft:set_count", "count": 2 }, "minecraft:some_modifier"] }A list of predicates reads as an and, and a list of modifiers applies in order, which is what Java does. resolveMembers covers the sibling member form, used by fields such as an item predicate's items, which name registry members instead of elements. A reference that points at itself reports a cycle rather than recursing.
Injectable seams
All of these are optional. A member a host leaves out makes the predicate that needs it report a diagnostic and evaluate false, rather than failing the whole parse.
ReferenceResolveron the parse options resolves namespaced ids to element JSON and tags to member ids. Without it, inline grammar still works and a reference is an error.RandomSourceon the context is the only randomness the evaluator uses, sorandom_chance,uniform,binomial,explosion_decayand the weighted list reproduce exactly in a test.scriptedRandom,constantRandomandseededRandomare built in.LevelViewanswers weather, the world clock, biomes, structures, light, blocks, fluids, command storage, scoreboards and environment attributes.ItemStackOpsowns stack construction, Bedrock auxiliary data, component writes, the stack size limit, and the durability limit, so a host keeps its own item type behind the minimal{ id, count, components, meta? }shape this package reads.EnchantmentViewanswers enchantment levels, maximum levels and the enchanting table draw.ContentViewanswers the few content questions the modifiers need and this package cannot own: smelting results, player profiles, exploration map search, loot entry rolls and the dye table.GrammarExtensionson the parse options registers entity sub-predicate and data component predicate types this package does not implement, keyed by namespaced id, merged over the built-in tables.
Loot context parameters
CONTEXT_PARAMETER_SETS holds the 31 context key sets of 26.3 with the required and optional parameters of each, read from LootContextParamSets in the server jar. Reading a parameter the declared set does not provide reports
the chest loot context does not provide block_stateand yields undefined, so a predicate attached to the wrong loot table fails loudly instead of quietly passing. A required parameter the host forgot to supply reports as well; an absent optional parameter does not.
Decisions worth knowing
The item stack shape is fixed and its operations are injectable. Threading a generic stack type through 20 conditions and 42 modifiers adds type noise without changing behavior, so a host adapts its own stack to { id, count, components } at the edge and controls allocation, component defaults and limits through ItemStackOps.
Float providers round to 32 bits. Java's float registry is float, not double, and the difference is visible: set_damage with a damage of 0.9 floors to 10 in Java and would floor to 9 in double arithmetic. Math.fround on every float draw reproduces Java's value.
An unregistered key in a predicates map is a presence check. 26.3 falls back to AnyValue when the key names a data component type rather than a predicate type, which is how vanilla writes {"minecraft:map_id": {}}. This package follows that and warns only when the ignored body is non-empty.
A tag that no resolver can expand is not an error in a member field. The subject often carries its own tag list, so resolveMembers keeps the tag name and matches against it.
Corpus test
corpus.test.ts parses the real Java 26.3 vanilla datapack out of the cached server jar and asserts the grammar reports nothing at all, neither errors nor warnings. It measures 3 predicate files, 26 int provider files, 4 float provider files, 1302 condition fields and 1098 modifier fields across 1447 loot tables, and 263 loot conditions across 1866 advancements. It 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.
License
MIT
Classes
Interfaces
BlockEntityView
Defined in: world.ts:23
The block entity behind the block_entity context parameter.
Properties
components?
readonlyoptionalcomponents?:ReadonlyMap<string,unknown>
Defined in: world.ts:28
Data components on the block entity, which copy_components copies onto the dropped item.
id
readonlyid:string
Defined in: world.ts:24
nbt?
readonlyoptionalnbt?:unknown
Defined in: world.ts:26
Parsed NBT, in whatever shape the host uses.
BlockState
Defined in: world.ts:11
A block state as Java names it: a block identifier plus its property values as strings.
Properties
name
readonlyname:string
Defined in: world.ts:12
properties?
readonlyoptionalproperties?:Readonly<Record<string,string>>
Defined in: world.ts:13
ContentView
Defined in: item.ts:116
Content lookups a few item modifiers need that this package cannot own, because smelting recipes, player profiles, structure search and the dye color table live elsewhere. An unimplemented member makes the modifier report a diagnostic and leave the stack unchanged.
Methods
dyeColors()?
optionaldyeColors(): readonlynumber[]
Defined in: item.ts:126
The packed RGB values of the dye colors, for set_random_dyes.
Returns
readonly number[]
explorationMap()?
optionalexplorationMap(stack,request):ItemStack|undefined
Defined in: item.ts:122
Builds the map item for exploration_map, or undefined when no structure was found.
Parameters
stack
request
Returns
ItemStack | undefined
profileOf()?
optionalprofileOf(entity):unknown
Defined in: item.ts:120
Value for the minecraft:profile component of an entity, for fill_player_head.
Parameters
entity
unknown
Returns
unknown
rollEntries()?
optionalrollEntries(entries): readonlyItemStack[] |undefined
Defined in: item.ts:124
Rolls loot pool entries into stacks, for set_contents.
Parameters
entries
unknown
Returns
readonly ItemStack[] | undefined
smeltingResult()?
optionalsmeltingResult(stack):ItemStack|undefined
Defined in: item.ts:118
Result of smelting one item, for furnace_smelt.
Parameters
stack
Returns
ItemStack | undefined
ContextParameterSet
Defined in: context.ts:38
Which parameters a context key set guarantees and which it only allows.
Properties
optional
readonlyoptional: readonly (keyofLootContextParameters)[]
Defined in: context.ts:40
required
readonlyrequired: readonly (keyofLootContextParameters)[]
Defined in: context.ts:39
DamageSource
Defined in: world.ts:127
The damage source behind the damage_source context parameter.
Properties
directEntity?
readonlyoptionaldirectEntity?:EntityView
Defined in: world.ts:133
The projectile or other entity that landed the hit.
position?
readonlyoptionalposition?:Vec3
Defined in: world.ts:136
sourceEntity?
readonlyoptionalsourceEntity?:EntityView
Defined in: world.ts:135
The entity that caused the hit, which is the shooter for a projectile.
tags?
readonlyoptionaltags?: readonlystring[]
Defined in: world.ts:131
Damage type tags, namespaced and without the leading #.
type
readonlytype:string
Defined in: world.ts:129
Namespaced damage type identifier, for example minecraft:arrow.
Diagnostic
Defined in: diagnostics.ts:5
One problem found while parsing or evaluating a predicate, modifier or provider.
Extended by
Properties
message
readonlymessage:string
Defined in: diagnostics.ts:9
path
readonlypath:string
Defined in: diagnostics.ts:8
Dotted path to the offending JSON member, for example terms[1].predicate.
severity
readonlyseverity:DiagnosticSeverity
Defined in: diagnostics.ts:6
EffectInstance
Defined in: world.ts:32
One status effect on an entity.
Properties
ambient
readonlyambient:boolean
Defined in: world.ts:36
amplifier
readonlyamplifier:number
Defined in: world.ts:33
duration
readonlyduration:number
Defined in: world.ts:35
Remaining duration in ticks.
visible
readonlyvisible:boolean
Defined in: world.ts:37
EnchantmentView
Defined in: item.ts:68
Enchantment facts the evaluator cannot derive from a stack alone. The enchantment registry lives in another package, so apply_bonus, table_bonus, enchant_randomly and enchant_with_levels read it through this seam. An unimplemented member makes the modifier report a diagnostic and leave the stack alone.
Methods
applicableTo()?
optionalapplicableTo(stack): readonlystring[]
Defined in: item.ts:74
Enchantments that may go on an item, used when enchant_randomly lists no options.
Parameters
stack
Returns
readonly string[]
levelOn()?
optionallevelOn(stack,enchantment):number
Defined in: item.ts:70
Level of an enchantment on a stack, or 0 when it is absent.
Parameters
stack
enchantment
string
Returns
number
maxLevel()?
optionalmaxLevel(enchantment):number|undefined
Defined in: item.ts:72
Highest level an enchantment reaches, used when enchant_randomly picks a level.
Parameters
enchantment
string
Returns
number | undefined
selectRandomEnchantments()?
optionalselectRandomEnchantments(stack,levels,options):ReadonlyMap<string,number> |undefined
Defined in: item.ts:76
Runs the enchanting table draw for enchant_with_levels.
Parameters
stack
levels
number
options
readonly string[] | undefined
Returns
ReadonlyMap<string, number> | undefined
EntityView
Defined in: world.ts:86
Everything the entity sub-predicates can ask about one entity. Every member is optional: a host fills in what it can answer, and a sub-predicate that reaches a member the host left out reports a diagnostic and fails.
Properties
components?
readonlyoptionalcomponents?:ReadonlyMap<string,unknown>
Defined in: world.ts:94
Data components on the entity, keyed by namespaced component type.
effects?
readonlyoptionaleffects?:ReadonlyMap<string,EffectInstance>
Defined in: world.ts:96
Active status effects, keyed by namespaced effect identifier.
equipment?
readonlyoptionalequipment?:Readonly<Partial<Record<"mainhand"|"offhand"|"head"|"chest"|"legs"|"feet"|"body"|"saddle",ItemStack>>>
Defined in: world.ts:97
experienceLevel?
readonlyoptionalexperienceLevel?:number
Defined in: world.ts:115
Experience level, read by type_specific/player.
flags?
readonlyoptionalflags?:Readonly<Partial<Record<"is_on_fire"|"is_sneaking"|"is_sprinting"|"is_swimming"|"is_baby"|"is_flying"|"is_on_ground"|"is_in_water"|"is_fall_flying",boolean>>>
Defined in: world.ts:92
food?
readonlyoptionalfood?:FoodView
Defined in: world.ts:119
Hunger state, read by type_specific/player.
gameMode?
readonlyoptionalgameMode?:string
Defined in: world.ts:117
Game mode identifier, read by type_specific/player.
lookingAt?
readonlyoptionallookingAt?:EntityView
Defined in: world.ts:103
The entity a player is looking at, read by type_specific/player.
movement?
readonlyoptionalmovement?:MovementView
Defined in: world.ts:111
movementAffectedBy?
readonlyoptionalmovementAffectedBy?:BlockState
Defined in: world.ts:110
The block the entity's movement is affected by, read by movement_affected_by.
nbt?
readonlyoptionalnbt?:unknown
Defined in: world.ts:123
Parsed NBT for the nbt sub-predicate, in whatever shape the host uses.
passenger?
readonlyoptionalpassenger?:EntityView
Defined in: world.ts:99
position?
readonlyoptionalposition?:Vec3
Defined in: world.ts:91
scores?
readonlyoptionalscores?:ReadonlyMap<string,number>
Defined in: world.ts:106
Scoreboard values, keyed by objective name.
steppingOn?
readonlyoptionalsteppingOn?:BlockState
Defined in: world.ts:108
The block under the entity's feet, read by stepping_on.
target?
readonlyoptionaltarget?:EntityView
Defined in: world.ts:101
The entity this one is attacking, read by the targeted_entity sub-predicate.
team?
readonlyoptionalteam?:string
Defined in: world.ts:104
ticksExisted?
readonlyoptionalticksExisted?:number
Defined in: world.ts:113
Age in ticks, read by periodic_tick.
type
readonlytype:string
Defined in: world.ts:88
Namespaced entity type identifier, for example minecraft:sheep.
typeSpecific?
readonlyoptionaltypeSpecific?:Readonly<Record<string,unknown>>
Defined in: world.ts:121
Whether the entity is a captain of a raid, whether a sheep is sheared, and the rest of the per-type flags.
typeTags?
readonlyoptionaltypeTags?: readonlystring[]
Defined in: world.ts:90
Entity type tags this entity belongs to, namespaced and without the leading #.
vehicle?
readonlyoptionalvehicle?:EntityView
Defined in: world.ts:98
ExplorationMapRequest
Defined in: item.ts:100
What exploration_map is asked to find.
Properties
decoration
readonlydecoration:string
Defined in: item.ts:104
Namespaced map decoration id.
destination
readonlydestination:string
Defined in: item.ts:102
Namespaced structure id or tag the map should point at.
searchRadius
readonlysearchRadius:number
Defined in: item.ts:106
skipExistingChunks
readonlyskipExistingChunks:boolean
Defined in: item.ts:107
zoom
readonlyzoom:number
Defined in: item.ts:105
FluidState
Defined in: world.ts:17
A fluid state, shaped like BlockState because Java's fluid sub-predicate reads the same way.
Properties
name
readonlyname:string
Defined in: world.ts:18
properties?
readonlyoptionalproperties?:Readonly<Record<string,string>>
Defined in: world.ts:19
FoodView
Defined in: world.ts:74
The hunger state the food member of type_specific/player reads.
Properties
level
readonlylevel:number
Defined in: world.ts:76
Food level, which runs from 0 to 20 in vanilla.
saturation
readonlysaturation:number
Defined in: world.ts:78
Saturation, which vanilla keeps at or below the food level.
GrammarExtensions
Defined in: parse.ts:23
The registry seam. Entries here are merged over the built-in tables, so a host can teach the evaluator a sub-predicate this package does not implement without forking it.
Properties
dataComponentPredicates?
readonlyoptionaldataComponentPredicates?:Readonly<Record<string,SubPredicateParser<ItemStack>>>
Defined in: parse.ts:27
Extra data component predicate types, keyed by namespaced id.
entitySubPredicates?
readonlyoptionalentitySubPredicates?:Readonly<Record<string,SubPredicateParser<EntityView>>>
Defined in: parse.ts:25
Extra entity sub-predicate types, keyed by namespaced id such as minecraft:type_specific/axolotl.
ItemStack
Defined in: item.ts:7
The smallest stack this package can work with: what the item is, how many of it there are, and its data components. The real item type lives in another package, so a host adapts its own stack to this shape at the edge and plugs the operations in through ItemStackOps.
Properties
components
readonlycomponents:ReadonlyMap<string,unknown>
Defined in: item.ts:14
Data components keyed by namespaced component type, for example minecraft:enchantments.
count
readonlycount:number
Defined in: item.ts:10
id
readonlyid:string
Defined in: item.ts:9
Namespaced item identifier, for example minecraft:diamond.
meta?
readonlyoptionalmeta?:number
Defined in: item.ts:12
Bedrock auxiliary item data, carried by loot functions such as set_data_from_color_index.
ItemStackOps
Defined in: item.ts:22
Every way an item modifier changes or inspects a stack. Injecting it lets a host keep its own allocation, component defaults and per-item limits while the 42 modifiers stay unchanged.
Methods
component()
component(
stack,type):unknown
Defined in: item.ts:31
Parameters
stack
type
string
Returns
unknown
create()
create(
id,count):ItemStack
Defined in: item.ts:24
Builds a fresh stack with no components.
Parameters
id
string
count
number
Returns
maxDamage()
maxDamage(
stack):number
Defined in: item.ts:35
Durability of the item, or 0 when it takes no damage.
Parameters
stack
Returns
number
maxStackSize()
maxStackSize(
stack):number
Defined in: item.ts:33
Largest count the item allows, which set_count and limit_count clamp to.
Parameters
stack
Returns
number
withComponent()
withComponent(
stack,type,value):ItemStack
Defined in: item.ts:30
Sets a component, or removes it when value is undefined.
Parameters
stack
type
string
value
unknown
Returns
withCount()
withCount(
stack,count):ItemStack
Defined in: item.ts:26
Parameters
stack
count
number
Returns
withId()
withId(
stack,id):ItemStack
Defined in: item.ts:25
Parameters
stack
id
string
Returns
withMeta()?
optionalwithMeta(stack,meta):ItemStack
Defined in: item.ts:28
Sets Bedrock's auxiliary item data, or clears it when undefined.
Parameters
stack
meta
number | undefined
Returns
LevelView
Defined in: world.ts:145
The world state the location, weather and time conditions read. Implement what the host can answer; a predicate that reaches an unimplemented member reports a diagnostic and evaluates false, which keeps a partial host usable instead of forcing a stub for every method.
Methods
biomeAt()?
optionalbiomeAt(position):string|undefined
Defined in: world.ts:155
Namespaced biome identifier at a position.
Parameters
position
Returns
string | undefined
biomeTagsAt()?
optionalbiomeTagsAt(position): readonlystring[]
Defined in: world.ts:157
Biome tags the biome at a position belongs to, namespaced and without the leading #.
Parameters
position
Returns
readonly string[]
blockAt()?
optionalblockAt(position):BlockState|undefined
Defined in: world.ts:152
Parameters
position
Returns
BlockState | undefined
canSeeSky()?
optionalcanSeeSky(position):boolean
Defined in: world.ts:162
Parameters
position
Returns
boolean
clockTicks()?
optionalclockTicks(clock):number
Defined in: world.ts:147
Total ticks on a world clock, for example minecraft:overworld, before the time_check period is applied.
Parameters
clock
string
Returns
number
dimension()?
optionaldimension():string
Defined in: world.ts:151
Namespaced dimension identifier of the level being evaluated.
Returns
string
environmentAttribute()?
optionalenvironmentAttribute(attribute,position):number|undefined
Defined in: world.ts:166
Value of an environment attribute at a position, for environment_attribute providers and checks.
Parameters
attribute
string
position
Vec3 | undefined
Returns
number | undefined
fluidAt()?
optionalfluidAt(position):FluidState|undefined
Defined in: world.ts:153
Parameters
position
Returns
FluidState | undefined
isRaining()?
optionalisRaining():boolean
Defined in: world.ts:148
Returns
boolean
isSmokey()?
optionalisSmokey(position):boolean
Defined in: world.ts:164
Whether a campfire below the position is producing smoke.
Parameters
position
Returns
boolean
isThundering()?
optionalisThundering():boolean
Defined in: world.ts:149
Returns
boolean
lightAt()?
optionallightAt(position):number
Defined in: world.ts:161
Combined light level at a position, which is what Java's light predicate compares.
Parameters
position
Returns
number
score()?
optionalscore(holder,objective):number|undefined
Defined in: world.ts:170
Scoreboard value for a holder name and objective, for score providers.
Parameters
holder
string
objective
string
Returns
number | undefined
storedNumber()?
optionalstoredNumber(storage,path):number|undefined
Defined in: world.ts:168
Value stored under a path in a command storage namespace, for storage providers.
Parameters
storage
string
path
string
Returns
number | undefined
structuresAt()?
optionalstructuresAt(position): readonlystring[]
Defined in: world.ts:159
Namespaced identifiers of the structures whose bounding box contains a position.
Parameters
position
Returns
readonly string[]
LootContextParameters
Defined in: context.ts:12
The 16 loot context parameters Java 26.3 registers in LootContextParams, with the type this package carries for each.
Properties
additional_cost_component_allowed?
optionaladditional_cost_component_allowed?:boolean
Defined in: context.ts:30
attacking_entity?
optionalattacking_entity?:EntityView
Defined in: context.ts:20
The entity behind the damage, which is the shooter for a projectile.
block_entity?
optionalblock_entity?:BlockEntityView
Defined in: context.ts:25
block_state?
optionalblock_state?:BlockState
Defined in: context.ts:24
container?
optionalcontainer?: readonlyItemStack[]
Defined in: context.ts:31
damage_source?
optionaldamage_source?:DamageSource
Defined in: context.ts:18
direct_attacking_entity?
optionaldirect_attacking_entity?:EntityView
Defined in: context.ts:22
The entity that landed the hit, which is the projectile itself.
enchantment_active?
optionalenchantment_active?:boolean
Defined in: context.ts:29
enchantment_level?
optionalenchantment_level?:number
Defined in: context.ts:28
explosion_radius?
optionalexplosion_radius?:number
Defined in: context.ts:27
interacting_entity?
optionalinteracting_entity?:EntityView
Defined in: context.ts:15
last_damage_player?
optionallast_damage_player?:EntityView
Defined in: context.ts:17
origin?
optionalorigin?:Vec3
Defined in: context.ts:23
target_entity?
optionaltarget_entity?:EntityView
Defined in: context.ts:16
this_entity?
optionalthis_entity?:EntityView
Defined in: context.ts:14
The entity the evaluation is about: the mob that died, the player opening the chest.
tool?
optionaltool?:ItemStack
Defined in: context.ts:26
MemberSet
Defined in: reference.ts:102
What the member form of the composition rule names: the identifiers written out directly or reached through a tag, and the tag names themselves.
Properties
ids
readonlyids:ReadonlySet<string>
Defined in: reference.ts:103
tags
readonlytags: readonlystring[]
Defined in: reference.ts:105
Namespaced tag names without the leading #, kept so a subject that carries its own tags still matches.
MovementView
Defined in: world.ts:63
The entity speed and offset the movement entity sub-predicate reads.
Properties
fallDistance?
readonlyoptionalfallDistance?:number
Defined in: world.ts:70
horizontalSpeed?
readonlyoptionalhorizontalSpeed?:number
Defined in: world.ts:68
speed?
readonlyoptionalspeed?:number
Defined in: world.ts:67
verticalSpeed?
readonlyoptionalverticalSpeed?:number
Defined in: world.ts:69
x?
readonlyoptionalx?:number
Defined in: world.ts:64
y?
readonlyoptionaly?:number
Defined in: world.ts:65
z?
readonlyoptionalz?:number
Defined in: world.ts:66
ParseOptions
Defined in: parse.ts:31
Everything the parsers can be told about the world they are parsing into.
Extended by
Properties
diagnostics?
optionaldiagnostics?:DiagnosticCollector
Defined in: parse.ts:35
Reuse a collector to gather diagnostics from several parses into one report.
extensions?
optionalextensions?:GrammarExtensions
Defined in: parse.ts:38
path?
optionalpath?:string
Defined in: parse.ts:37
Prefix for diagnostic paths, such as the file the JSON came from.
resolver?
optionalresolver?:ReferenceResolver
Defined in: parse.ts:33
Resolves namespaced ids and #tag references; without it a reference reports an error.
ParseResult
Defined in: parse.ts:42
A compiled grammar member together with everything that went wrong while compiling it.
Type Parameters
T
T
Properties
diagnostics
readonlydiagnostics: readonlyDiagnostic[]
Defined in: parse.ts:44
value
readonlyvalue:T
Defined in: parse.ts:43
PredicateContextOptions
Defined in: context.ts:118
Everything PredicateContext needs, all of it optional so a test can supply only what it exercises.
Properties
content?
optionalcontent?:ContentView
Defined in: context.ts:129
diagnostics?
optionaldiagnostics?:DiagnosticCollector
Defined in: context.ts:126
Defaults to a fresh collector, reachable as PredicateContext.diagnostics.
enchantments?
optionalenchantments?:EnchantmentView
Defined in: context.ts:128
items?
optionalitems?:ItemStackOps
Defined in: context.ts:127
level?
optionallevel?:LevelView
Defined in: context.ts:124
parameters?
optionalparameters?:LootContextParameters
Defined in: context.ts:121
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: context.ts:120
Defaults to empty, which declares no parameters and so reports every read.
random?
optionalrandom?:RandomSource
Defined in: context.ts:123
Defaults to a source that always draws 0.5.
RandomSource
Defined in: random.ts:6
The only source of randomness the evaluator uses. Injecting it is what makes a loot roll, a random_chance check or a uniform provider reproducible in a test.
Extended by
Methods
nextFloat()
nextFloat():
number
Defined in: random.ts:8
Returns a float in the half-open interval [0, 1).
Returns
number
nextInt()
nextInt(
bound):number
Defined in: random.ts:10
Returns an integer in the half-open interval [0, bound).
Parameters
bound
number
Returns
number
ReferenceResolver
Defined in: reference.ts:50
How the evaluator reaches the rest of the datapack. Both members are optional so a host that only uses inline grammar needs no resolver at all; a reference with nothing to resolve it reports an error.
Methods
element()?
optionalelement(registry,id):unknown
Defined in: reference.ts:52
Returns the parsed JSON of a registry element, or undefined when the id is unknown.
Parameters
registry
"advancement" | "item_modifier" | "loot_table" | "context_int_provider" | "context_float_provider" | "predicate" | "recipe" | "slot_source"
id
string
Returns
unknown
tag()?
optionaltag(registry,id): readonlystring[] |undefined
Defined in: reference.ts:54
Returns the namespaced member ids of a tag, or undefined when the tag is unknown.
Parameters
registry
id
string
Returns
readonly string[] | undefined
SeededRandomState
Defined in: random.ts:14
JSON-safe state captured by seededRandom.
Properties
algorithm
readonlyalgorithm:"mulberry32"
Defined in: random.ts:16
state
readonlystate:number
Defined in: random.ts:18
The generator's current unsigned 32-bit counter.
version
readonlyversion:1
Defined in: random.ts:15
StatefulRandomSource
Defined in: random.ts:22
A seeded source that can resume from a JSON-safe state.
Extends
Methods
nextFloat()
nextFloat():
number
Defined in: random.ts:8
Returns a float in the half-open interval [0, 1).
Returns
number
Inherited from
nextInt()
nextInt(
bound):number
Defined in: 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: random.ts:26
Resumes this stream from a state produced by seededRandom.
Parameters
state
unknown
Returns
void
saveState()
saveState():
SeededRandomState
Defined in: random.ts:24
Returns the state needed to continue this exact stream.
Returns
Vec3
Defined in: world.ts:4
A position in world space.
Properties
x
readonlyx:number
Defined in: world.ts:5
y
readonlyy:number
Defined in: world.ts:6
z
readonlyz:number
Defined in: world.ts:7
Type Aliases
BlockMatcher
BlockMatcher = (
state,blockEntity,context) =>boolean
Defined in: subpredicates.ts:36
Answers whether a block state and its block entity match.
Parameters
state
BlockState | undefined
blockEntity
BlockEntityView | undefined
context
Returns
boolean
ContextParameterSetName
ContextParameterSetName = keyof typeof
CONTEXT_PARAMETER_SETS
Defined in: context.ts:110
One of the keys of CONTEXT_PARAMETER_SETS.
DamageSourceMatcher
DamageSourceMatcher = (
source,context) =>boolean
Defined in: subpredicates.ts:52
Answers whether a damage source matches.
Parameters
source
DamageSource | undefined
context
Returns
boolean
DiagnosticSeverity
DiagnosticSeverity =
"error"|"warning"
Defined in: diagnostics.ts:2
How much a diagnostic matters to the caller.
ElementRegistry
ElementRegistry = typeof
ELEMENT_REGISTRIES[number]
Defined in: reference.ts:20
One of ELEMENT_REGISTRIES.
EntityFlag
EntityFlag = typeof
ENTITY_FLAGS[number]
Defined in: world.ts:60
One of ENTITY_FLAGS.
EntityMatcher
EntityMatcher = (
entity,context) =>boolean
Defined in: subpredicates.ts:30
Answers whether one entity matches, where undefined means there is no such entity.
Parameters
entity
EntityView | undefined
context
Returns
boolean
EntityTarget
EntityTarget = keyof typeof
ENTITY_TARGETS
Defined in: providers.ts:35
One of the keys of ENTITY_TARGETS.
EquipmentSlot
EquipmentSlot = typeof
EQUIPMENT_SLOTS[number]
Defined in: world.ts:44
One of EQUIPMENT_SLOTS.
FluidMatcher
FluidMatcher = (
state,context) =>boolean
Defined in: subpredicates.ts:43
Answers whether a fluid state matches.
Parameters
state
FluidState | undefined
context
Returns
boolean
IdRegistry
IdRegistry = typeof
ID_REGISTRIES[number]
Defined in: reference.ts:40
One of ID_REGISTRIES.
ItemMatcher
ItemMatcher = (
stack,context) =>boolean
Defined in: subpredicates.ts:33
Answers whether one item stack matches.
Parameters
stack
ItemStack | undefined
context
Returns
boolean
ItemModifier
ItemModifier = (
stack,context) =>ItemStack|undefined
Defined in: modifiers.ts:17
A compiled item modifier, which Java also stores on its own as an item_modifier file. Returning undefined means the modifier discarded the stack.
Parameters
stack
context
Returns
ItemStack | undefined
JsonObject
JsonObject =
Readonly<Record<string,unknown>>
Defined in: json.ts:2
A JSON object after JSON.parse, before this package has checked its members.
LevelBasedValue
LevelBasedValue = (
level) =>number
Defined in: providers.ts:14
An enchantment level based value, which maps an enchantment level to a number.
Parameters
level
number
Returns
number
LocationMatcher
LocationMatcher = (
position,context,block?) =>boolean
Defined in: subpredicates.ts:49
Answers whether a position matches. block overrides what the level would report, which is how stepping_on checks the block under an entity.
Parameters
position
Vec3 | undefined
context
block?
Returns
boolean
LootConditionType
LootConditionType = typeof
LOOT_CONDITION_TYPES[number]
Defined in: conditions.ts:46
One of LOOT_CONDITION_TYPES.
LootContextParameter
LootContextParameter = keyof
LootContextParameters
Defined in: context.ts:35
One of the keys of LootContextParameters.
LootFunctionType
LootFunctionType = typeof
LOOT_FUNCTION_TYPES[number]
Defined in: modifiers.ts:66
One of LOOT_FUNCTION_TYPES.
NumberProvider
NumberProvider = (
context) =>number
Defined in: providers.ts:11
A number provider compiled once and drawn from a context.
Parameters
context
Returns
number
Predicate
Predicate = (
context) =>boolean
Defined in: conditions.ts:19
A compiled loot condition, which Java also stores on its own as a predicate file.
Parameters
context
Returns
boolean
ProviderKind
ProviderKind =
"int"|"float"
Defined in: providers.ts:17
Which of Java's two provider registries a value is parsed against.
RangeTest
RangeTest = (
value,context) =>boolean
Defined in: subpredicates.ts:27
Answers whether a number passes a range or exact check from the grammar.
Parameters
value
number
context
Returns
boolean
ReferenceRegistry
ReferenceRegistry =
ElementRegistry|IdRegistry
Defined in: reference.ts:43
Any registry a reference can point into.
SubPredicateParser
SubPredicateParser<
TSubject> = (value,context) => (subject,evaluation) =>boolean
Defined in: parse.ts:13
Compiles one member of a sub-grammar keyed by type id. The returned matcher answers for one subject against a context.
Type Parameters
TSubject
TSubject
Parameters
value
unknown
context
Returns
(subject, evaluation) => boolean
Variables
CONTEXT_PARAMETER_SETS
constCONTEXT_PARAMETER_SETS:object
Defined in: context.ts:49
The 31 context key sets of Java 26.3, read out of LootContextParamSets.<clinit> in the 26.3 server jar. Evaluating a predicate against the wrong set is what the missing-parameter diagnostic catches.
Type Declaration
advancement_entity
readonlyadvancement_entity:object
advancement_entity.optional
readonlyoptional: readonly [] =[]
advancement_entity.required
readonlyrequired: readonly ["this_entity","origin"]
advancement_location
readonlyadvancement_location:object
advancement_location.optional
readonlyoptional: readonly ["block_entity"]
advancement_location.required
readonlyrequired: readonly ["this_entity","origin","tool","block_state"]
advancement_reward
readonlyadvancement_reward:object
advancement_reward.optional
readonlyoptional: readonly [] =[]
advancement_reward.required
readonlyrequired: readonly ["this_entity","origin"]
archaeology
readonlyarchaeology:object
archaeology.optional
readonlyoptional: readonly [] =[]
archaeology.required
readonlyrequired: readonly ["origin","this_entity","tool"]
barter
readonlybarter:object
barter.optional
readonlyoptional: readonly [] =[]
barter.required
readonlyrequired: readonly ["this_entity"]
block
readonlyblock:object
block.optional
readonlyoptional: readonly ["this_entity","block_entity","explosion_radius"]
block.required
readonlyrequired: readonly ["block_state","origin","tool"]
block_interact
readonlyblock_interact:object
block_interact.optional
readonlyoptional: readonly ["block_entity","interacting_entity","tool"]
block_interact.required
readonlyrequired: readonly ["block_state","origin"]
block_use
readonlyblock_use:object
block_use.optional
readonlyoptional: readonly [] =[]
block_use.required
readonlyrequired: readonly ["this_entity","origin","block_state"]
chest
readonlychest:object
chest.optional
readonlyoptional: readonly ["this_entity"]
chest.required
readonlyrequired: readonly ["origin"]
command
readonlycommand:object
command.optional
readonlyoptional: readonly ["this_entity"]
command.required
readonlyrequired: readonly ["origin"]
command_compute_default
readonlycommand_compute_default:object
command_compute_default.optional
readonlyoptional: readonly ["this_entity"]
command_compute_default.required
readonlyrequired: readonly ["origin"]
command_compute_entity
readonlycommand_compute_entity:object
command_compute_entity.optional
readonlyoptional: readonly ["this_entity"]
command_compute_entity.required
readonlyrequired: readonly ["origin","target_entity"]
command_compute_position
readonlycommand_compute_position:object
command_compute_position.optional
readonlyoptional: readonly ["this_entity","block_entity"]
command_compute_position.required
readonlyrequired: readonly ["origin","block_state"]
command_slot_source
readonlycommand_slot_source:object
command_slot_source.optional
readonlyoptional: readonly ["this_entity"]
command_slot_source.required
readonlyrequired: readonly ["origin","container"]
container_process
readonlycontainer_process:object
container_process.optional
readonlyoptional: readonly [] =[]
container_process.required
readonlyrequired: readonly ["block_entity","block_state","container","origin"]
empty
readonlyempty:object
empty.optional
readonlyoptional: readonly [] =[]
empty.required
readonlyrequired: readonly [] =[]
enchanted_damage
readonlyenchanted_damage:object
enchanted_damage.optional
readonlyoptional: readonly ["direct_attacking_entity","attacking_entity"]
enchanted_damage.required
readonlyrequired: readonly ["this_entity","enchantment_level","origin","damage_source"]
enchanted_entity
readonlyenchanted_entity:object
enchanted_entity.optional
readonlyoptional: readonly [] =[]
enchanted_entity.required
readonlyrequired: readonly ["this_entity","enchantment_level","origin"]
enchanted_item
readonlyenchanted_item:object
enchanted_item.optional
readonlyoptional: readonly [] =[]
enchanted_item.required
readonlyrequired: readonly ["tool","enchantment_level"]
enchanted_location
readonlyenchanted_location:object
enchanted_location.optional
readonlyoptional: readonly [] =[]
enchanted_location.required
readonlyrequired: readonly ["this_entity","enchantment_level","origin","enchantment_active"]
entity
readonlyentity:object
entity.optional
readonlyoptional: readonly ["attacking_entity","direct_attacking_entity","last_damage_player"]
entity.required
readonlyrequired: readonly ["this_entity","origin","damage_source"]
entity_interact
readonlyentity_interact:object
entity_interact.optional
readonlyoptional: readonly ["interacting_entity"]
entity_interact.required
readonlyrequired: readonly ["target_entity","tool"]
equipment
readonlyequipment:object
equipment.optional
readonlyoptional: readonly [] =[]
equipment.required
readonlyrequired: readonly ["origin","this_entity"]
fishing
readonlyfishing:object
fishing.optional
readonlyoptional: readonly ["this_entity"]
fishing.required
readonlyrequired: readonly ["origin","tool"]
generic
readonlygeneric:object
generic.optional
readonlyoptional: readonly [] =[]
generic.required
readonlyrequired: readonly ["this_entity","last_damage_player","damage_source","attacking_entity","direct_attacking_entity","origin","block_state"]
gift
readonlygift:object
gift.optional
readonlyoptional: readonly [] =[]
gift.required
readonlyrequired: readonly ["origin","this_entity"]
hit_block
readonlyhit_block:object
hit_block.optional
readonlyoptional: readonly [] =[]
hit_block.required
readonlyrequired: readonly ["this_entity","enchantment_level","origin","block_state"]
selector
readonlyselector:object
selector.optional
readonlyoptional: readonly [] =[]
selector.required
readonlyrequired: readonly ["origin","this_entity"]
shearing
readonlyshearing:object
shearing.optional
readonlyoptional: readonly [] =[]
shearing.required
readonlyrequired: readonly ["origin","this_entity","tool"]
vault
readonlyvault:object
vault.optional
readonlyoptional: readonly ["this_entity"]
vault.required
readonlyrequired: readonly ["origin","tool"]
villager_trade
readonlyvillager_trade:object
villager_trade.optional
readonlyoptional: readonly [] =[]
villager_trade.required
readonlyrequired: readonly ["origin","this_entity","additional_cost_component_allowed"]
DATA_COMPONENT_PREDICATES
constDATA_COMPONENT_PREDICATES: readonlystring[] =DATA_COMPONENT_PREDICATE_TYPES
Defined in: subpredicates.ts:153
The 15 data component predicate types Java 26.3 registers.
ELEMENT_REGISTRIES
constELEMENT_REGISTRIES: readonly ["advancement","item_modifier","loot_table","context_int_provider","context_float_provider","predicate","recipe","slot_source"]
Defined in: reference.ts:8
The eight registries 26.3 made composable: a field of one of these types takes an inline value, a namespaced id, a list, or a #tag.
ENTITY_FLAGS
constENTITY_FLAGS: readonly ["is_on_fire","is_sneaking","is_sprinting","is_swimming","is_baby","is_flying","is_on_ground","is_in_water","is_fall_flying"]
Defined in: world.ts:47
Every flag Java's flags entity sub-predicate can test.
ENTITY_SUB_PREDICATES
constENTITY_SUB_PREDICATES: readonly ["minecraft:entity_type","minecraft:location","minecraft:stepping_on","minecraft:movement_affected_by","minecraft:distance","minecraft:movement","minecraft:effects","minecraft:nbt","minecraft:flags","minecraft:equipment","minecraft:periodic_tick","minecraft:vehicle","minecraft:passenger","minecraft:targeted_entity","minecraft:team","minecraft:slots","minecraft:components","minecraft:predicates","minecraft:entity_tags","minecraft:type_specific/lightning","minecraft:type_specific/fishing_hook","minecraft:type_specific/player","minecraft:type_specific/cube_mob","minecraft:type_specific/raider","minecraft:type_specific/sheep"]
Defined in: subpredicates.ts:392
The 25 entity sub-predicate types Java 26.3 registers.
ENTITY_TARGETS
constENTITY_TARGETS:object
Defined in: providers.ts:25
The six entity targets a loot context can name, mapped to the parameter each reads.
Type Declaration
attacker
readonlyattacker:"attacking_entity"='attacking_entity'
attacking_player
readonlyattacking_player:"last_damage_player"='last_damage_player'
direct_attacker
readonlydirect_attacker:"direct_attacking_entity"='direct_attacking_entity'
interacting_entity
readonlyinteracting_entity:"interacting_entity"='interacting_entity'
target_entity
readonlytarget_entity:"target_entity"='target_entity'
this
readonlythis:"this_entity"='this_entity'
EQUIPMENT_SLOTS
constEQUIPMENT_SLOTS: readonly ["mainhand","offhand","head","chest","legs","feet","body","saddle"]
Defined in: world.ts:41
Every slot Java's equipment entity sub-predicate can name.
ID_REGISTRIES
constID_REGISTRIES: readonly ["item","block","entity_type","enchantment","fluid","damage_type","mob_effect","worldgen/biome","worldgen/structure"]
Defined in: reference.ts:27
Registries this package only ever reads tags from. A field like an item predicate's items names members, not elements, so a #tag there expands into identifiers rather than JSON.
LOOT_CONDITION_TYPES
constLOOT_CONDITION_TYPES: readonly ["inverted","any_of","all_of","random_chance","random_chance_with_enchanted_bonus","entity_properties","killed_by_player","entity_scores","match_block","match_tool","table_bonus","survives_explosion","damage_source_properties","location_check","weather_check","time_check","int_value_check","float_value_check","enchantment_active_check","environment_attribute_check"]
Defined in: conditions.ts:22
The 20 loot condition types Java 26.3 registers in LootItemConditionTypes.
LOOT_FUNCTION_TYPES
constLOOT_FUNCTION_TYPES: readonly ["set_count","set_item","enchant_with_levels","enchant_randomly","set_enchantments","set_custom_data","set_components","furnace_smelt","enchanted_count_increase","set_damage","set_attributes","set_name","exploration_map","set_stew_effect","copy_name","set_contents","modify_contents","filtered","limit_count","apply_bonus","set_loot_table","explosion_decay","set_lore","fill_player_head","copy_custom_data","copy_state","set_banner_pattern","set_potion","set_random_dyes","set_random_potion","set_instrument","sequence","copy_components","set_fireworks","set_firework_explosion","set_book_cover","set_written_book_pages","set_writable_book_pages","toggle_tooltips","set_ominous_bottle_amplifier","set_custom_model_data","discard"]
Defined in: modifiers.ts:20
The 42 loot function types Java 26.3 registers in LootItemFunctions.
defaultEnchantmentView
constdefaultEnchantmentView:EnchantmentView
Defined in: item.ts:130
An EnchantmentView that only knows what the stack's own components say.
defaultItemStackOps
constdefaultItemStackOps:ItemStackOps
Defined in: item.ts:50
Immutable record operations over the built-in ItemStack. Every item stacks to 64 and takes no damage, because this package has no item registry; a host with one should override maxStackSize and maxDamage.
Functions
asArray()
asArray(
value): readonlyunknown[]
Defined in: json.ts:22
Wraps a single value in an array and leaves an array alone, which is how Java's list codecs read.
Parameters
value
unknown
Returns
readonly unknown[]
asBoolean()
asBoolean(
value):boolean|undefined
Defined in: json.ts:19
Returns value when it is a boolean, otherwise undefined.
Parameters
value
unknown
Returns
boolean | undefined
asList()
asList(
value): readonlyunknown[]
Defined in: json.ts:26
Returns the elements of value when it is an array, and nothing otherwise.
Parameters
value
unknown
Returns
readonly unknown[]
asNumber()
asNumber(
value):number|undefined
Defined in: json.ts:15
Returns value when it is a finite number, otherwise undefined.
Parameters
value
unknown
Returns
number | undefined
asString()
asString(
value):string|undefined
Defined in: json.ts:12
Returns value when it is a string, otherwise undefined.
Parameters
value
unknown
Returns
string | undefined
blockPredicate()
blockPredicate(
value,context):BlockMatcher
Defined in: subpredicates.ts:272
Parses Java's BlockPredicate: which blocks, which state properties, and which block entity data.
Parameters
value
unknown
context
Returns
constantRandom()
constantRandom(
value):RandomSource
Defined in: random.ts:59
A source that always draws the same float.
Parameters
value
number
Returns
damageSourcePredicate()
damageSourcePredicate(
value,context):DamageSourceMatcher
Defined in: subpredicates.ts:711
Parses Java's DamageSourcePredicate.
Parameters
value
unknown
context
Returns
enchantmentLevelFromComponent()
enchantmentLevelFromComponent(
stack,enchantment):number
Defined in: item.ts:88
Reads the level of an enchantment from the minecraft:enchantments component, accepting both the {"levels": {...}} wrapper Java writes and a bare identifier-to-level map.
Parameters
stack
enchantment
string
Returns
number
entityPredicate()
entityPredicate(
value,context):EntityMatcher
Defined in: subpredicates.ts:688
Parses Java 26.3's entity predicate, which is a map from entity sub-predicate type to its value. A type this package does not implement reports a diagnostic and evaluates false rather than throwing, and a host can supply its own through GrammarExtensions.
Parameters
value
unknown
context
Returns
floatProviderAt()
floatProviderAt(
value,context):NumberProvider
Defined in: providers.ts:318
Parses a value that may be a number, a reference, or an inline float provider object.
Parameters
value
unknown
context
Returns
floatRange()
floatRange(
value,context):RangeTest
Defined in: subpredicates.ts:78
Parses a float range: an exact float provider, or a {min, max} pair of them.
Parameters
value
unknown
context
Returns
fluidPredicate()
fluidPredicate(
value,context):FluidMatcher
Defined in: subpredicates.ts:291
Parses Java's FluidPredicate.
Parameters
value
unknown
context
Returns
intProviderAt()
intProviderAt(
value,context):NumberProvider
Defined in: providers.ts:314
Parses a value that may be a number, a reference, or an inline int provider object.
Parameters
value
unknown
context
Returns
intRange()
intRange(
value,context):RangeTest
Defined in: subpredicates.ts:75
Parses an int range: an exact int provider, or a {min, max} pair of them.
Parameters
value
unknown
context
Returns
isEntityTarget()
isEntityTarget(
value): value is "interacting_entity" | "target_entity" | "this" | "attacker" | "direct_attacker" | "attacking_player"
Defined in: providers.ts:38
Whether a string names one of ENTITY_TARGETS.
Parameters
value
string
Returns
value is "interacting_entity" | "target_entity" | "this" | "attacker" | "direct_attacker" | "attacking_player"
isJsonObject()
isJsonObject(
value):value is Readonly<Record<string, unknown>>
Defined in: json.ts:5
Narrows a parsed JSON value to an object.
Parameters
value
unknown
Returns
value is Readonly<Record<string, unknown>>
isStatefulRandomSource()
isStatefulRandomSource(
source):source is StatefulRandomSource
Defined in: random.ts:30
Whether an injected random source can be included in a replay state.
Parameters
source
Returns
source is StatefulRandomSource
isTagReference()
isTagReference(
value):boolean
Defined in: reference.ts:58
Whether a JSON string is a tag reference rather than an element id.
Parameters
value
string
Returns
boolean
itemPredicate()
itemPredicate(
value,context):ItemMatcher
Defined in: subpredicates.ts:251
Parses Java's ItemPredicate: which items, how many, and which components.
Parameters
value
unknown
context
Returns
joinPath()
joinPath(
path,segment):string
Defined in: json.ts:32
Adds a member name to a diagnostic path, using bracket notation for array indices so terms and terms[0] read the way the JSON does.
Parameters
path
string
segment
string | number
Returns
string
levelBasedValueAt()
levelBasedValueAt(
value,context):LevelBasedValue
Defined in: providers.ts:362
Parses an enchantment level based value, which may be a bare number or a typed object.
Parameters
value
unknown
context
Returns
locationPredicate()
locationPredicate(
value,context):LocationMatcher
Defined in: subpredicates.ts:328
Parses Java's LocationPredicate: biome, structure, dimension, light, block, fluid and sky checks at a position.
Parameters
value
unknown
context
Returns
member()
member(
value,key):unknown
Defined in: json.ts:9
Reads a member of a parsed JSON object, or undefined when the value is not an object.
Parameters
value
unknown
key
string
Returns
unknown
modifierAt()
modifierAt(
value,context):ItemModifier
Defined in: modifiers.ts:812
Parses an item modifier field under 26.3's composition rule and applies the resolved modifiers in order. A field that resolves to nothing leaves the stack alone.
Parameters
value
unknown
context
Returns
namespaced()
namespaced(
id):string
Defined in: json.ts:39
Normalizes a Minecraft identifier to its namespaced form so stone and minecraft:stone compare equal.
Parameters
id
string
Returns
string
parseComposed()
parseComposed<
T>(value,registry,context,parseInline):T[]
Defined in: reference.ts:150
Parses one field under 26.3's composition rule, which the plan calls the clearest rule in the format: the value may be an inline object, a namespaced id of a registry element, a list mixing both, or a #tag naming elements. Every predicate, item modifier and provider field goes through here.
Type Parameters
T
T
Parameters
value
unknown
registry
"advancement" | "item_modifier" | "loot_table" | "context_int_provider" | "context_float_provider" | "predicate" | "recipe" | "slot_source"
context
parseInline
(value, context) => T | undefined
Compiles one inline value; called once per resolved element.
Returns
T[]
One compiled value per element, in the order the composition names them.
parseComposedOne()
parseComposedOne<
T>(value,registry,context,parseInline):T|undefined
Defined in: reference.ts:199
The single-element form of parseComposed. Reports when a field that takes one element is given several.
Type Parameters
T
T
Parameters
value
unknown
registry
"advancement" | "item_modifier" | "loot_table" | "context_int_provider" | "context_float_provider" | "predicate" | "recipe" | "slot_source"
context
parseInline
(value, context) => T | undefined
Returns
T | undefined
parseFloatProvider()
parseFloatProvider(
value,options?):ParseResult<NumberProvider>
Defined in: providers.ts:387
Compiles a float provider from parsed JSON.
Parameters
value
unknown
options?
Returns
parseIntProvider()
parseIntProvider(
value,options?):ParseResult<NumberProvider>
Defined in: providers.ts:381
Compiles an int provider from parsed JSON.
Parameters
value
unknown
options?
Returns
parseItemModifier()
parseItemModifier(
value,options?):ParseResult<ItemModifier>
Defined in: modifiers.ts:824
Compiles an item modifier, an item_modifier file, or a loot function field from parsed JSON.
Parameters
value
unknown
options?
Returns
parseLevelBasedValue()
parseLevelBasedValue(
value,options?):ParseResult<LevelBasedValue>
Defined in: providers.ts:393
Compiles an enchantment level based value from parsed JSON.
Parameters
value
unknown
options?
Returns
parsePredicate()
parsePredicate(
value,options?):ParseResult<Predicate>
Defined in: conditions.ts:281
Compiles a predicate, a predicate file, or a loot condition field from parsed JSON.
Parameters
value
unknown
options?
Returns
predicateAt()
predicateAt(
value,context):Predicate
Defined in: conditions.ts:274
Parses a predicate field under 26.3's composition rule and folds the result with and, which is how Java treats a list of conditions. A field that resolves to nothing passes, matching an absent conditions list.
Parameters
value
unknown
context
Returns
resolveMembers()
resolveMembers(
value,registry,context):MemberSet
Defined in: reference.ts:115
Resolves the member form of 26.3's composition rule: a single namespaced id, a list of ids, or a #tag. Use it for fields that name registry members rather than elements, such as an item predicate's items. A tag that no resolver can expand is not an error, because the subject may know its own tags.
Parameters
value
unknown
registry
context
Returns
rootContext()
rootContext(
options?):ParseContext
Defined in: parse.ts:102
Builds the root parse context from caller options.
Parameters
options?
ParseOptions = {}
Returns
scriptedRandom()
scriptedRandom(
values):RandomSource
Defined in: random.ts:45
A source that replays values in order and starts over when it runs out. nextInt scales the same float into the bound.
Parameters
values
readonly number[]
Returns
seededRandom()
seededRandom(
seed):StatefulRandomSource
Defined in: random.ts:69
A mulberry32 generator. It is not Java's Random, so it reproduces runs of this server rather than Java Edition's exact draws; use it where a test needs many values rather than a scripted few.
Parameters
seed
number
Returns
statePropertiesTest()
statePropertiesTest(
value,context): (properties) =>boolean
Defined in: subpredicates.ts:102
Parses Java's state properties predicate: a map from property name to an exact value or a {min, max} pair, compared numerically when both sides are numbers and as text otherwise.
Parameters
value
unknown
context
Returns
(properties) => boolean
targetEntity()
targetEntity(
context,target,path):EntityView|undefined
Defined in: providers.ts:41
Reads the entity a loot context target names, reporting through the context when it cannot.
Parameters
context
target
"interacting_entity" | "target_entity" | "this" | "attacker" | "direct_attacker" | "attacking_player"
path
string
Returns
EntityView | undefined