Skip to content

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 ​

bash
pnpm add @jsprismarine/predicates

Using it ​

typescript
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 ​

Registry26.3 registersThis package
loot_condition_type2020
loot_function_type4242
context_int_provider_type2323
context_float_provider_type2828
enchantment_level_based_value_type6 plus the bare-number constant7
loot_score_provider_type22
loot_nbt_provider_type21, storage reported
entity_sub_predicate_type2523, with nbt and slots reported
data_component_predicate_type154 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.

json
{ "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.

  • ReferenceResolver on 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.
  • RandomSource on the context is the only randomness the evaluator uses, so random_chance, uniform, binomial, explosion_decay and the weighted list reproduce exactly in a test. scriptedRandom, constantRandom and seededRandom are built in.
  • LevelView answers weather, the world clock, biomes, structures, light, blocks, fluids, command storage, scoreboards and environment attributes.
  • ItemStackOps owns 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.
  • EnchantmentView answers enchantment levels, maximum levels and the enchanting table draw.
  • ContentView answers 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.
  • GrammarExtensions on 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_state

and 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? ​

readonly optional components?: ReadonlyMap<string, unknown>

Defined in: world.ts:28

Data components on the block entity, which copy_components copies onto the dropped item.

id ​

readonly id: string

Defined in: world.ts:24

nbt? ​

readonly optional nbt?: 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 ​

readonly name: string

Defined in: world.ts:12

properties? ​

readonly optional properties?: 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()? ​

optional dyeColors(): readonly number[]

Defined in: item.ts:126

The packed RGB values of the dye colors, for set_random_dyes.

Returns ​

readonly number[]

explorationMap()? ​

optional explorationMap(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 ​

ItemStack

request ​

ExplorationMapRequest

Returns ​

ItemStack | undefined

profileOf()? ​

optional profileOf(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()? ​

optional rollEntries(entries): readonly ItemStack[] | undefined

Defined in: item.ts:124

Rolls loot pool entries into stacks, for set_contents.

Parameters ​
entries ​

unknown

Returns ​

readonly ItemStack[] | undefined

smeltingResult()? ​

optional smeltingResult(stack): ItemStack | undefined

Defined in: item.ts:118

Result of smelting one item, for furnace_smelt.

Parameters ​
stack ​

ItemStack

Returns ​

ItemStack | undefined


ContextParameterSet ​

Defined in: context.ts:38

Which parameters a context key set guarantees and which it only allows.

Properties ​

optional ​

readonly optional: readonly (keyof LootContextParameters)[]

Defined in: context.ts:40

required ​

readonly required: readonly (keyof LootContextParameters)[]

Defined in: context.ts:39


DamageSource ​

Defined in: world.ts:127

The damage source behind the damage_source context parameter.

Properties ​

directEntity? ​

readonly optional directEntity?: EntityView

Defined in: world.ts:133

The projectile or other entity that landed the hit.

position? ​

readonly optional position?: Vec3

Defined in: world.ts:136

sourceEntity? ​

readonly optional sourceEntity?: EntityView

Defined in: world.ts:135

The entity that caused the hit, which is the shooter for a projectile.

tags? ​

readonly optional tags?: readonly string[]

Defined in: world.ts:131

Damage type tags, namespaced and without the leading #.

type ​

readonly type: 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 ​

readonly message: string

Defined in: diagnostics.ts:9

path ​

readonly path: string

Defined in: diagnostics.ts:8

Dotted path to the offending JSON member, for example terms[1].predicate.

severity ​

readonly severity: DiagnosticSeverity

Defined in: diagnostics.ts:6


EffectInstance ​

Defined in: world.ts:32

One status effect on an entity.

Properties ​

ambient ​

readonly ambient: boolean

Defined in: world.ts:36

amplifier ​

readonly amplifier: number

Defined in: world.ts:33

duration ​

readonly duration: number

Defined in: world.ts:35

Remaining duration in ticks.

visible ​

readonly visible: 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()? ​

optional applicableTo(stack): readonly string[]

Defined in: item.ts:74

Enchantments that may go on an item, used when enchant_randomly lists no options.

Parameters ​
stack ​

ItemStack

Returns ​

readonly string[]

levelOn()? ​

optional levelOn(stack, enchantment): number

Defined in: item.ts:70

Level of an enchantment on a stack, or 0 when it is absent.

Parameters ​
stack ​

ItemStack

enchantment ​

string

Returns ​

number

maxLevel()? ​

optional maxLevel(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()? ​

optional selectRandomEnchantments(stack, levels, options): ReadonlyMap<string, number> | undefined

Defined in: item.ts:76

Runs the enchanting table draw for enchant_with_levels.

Parameters ​
stack ​

ItemStack

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? ​

readonly optional components?: ReadonlyMap<string, unknown>

Defined in: world.ts:94

Data components on the entity, keyed by namespaced component type.

effects? ​

readonly optional effects?: ReadonlyMap<string, EffectInstance>

Defined in: world.ts:96

Active status effects, keyed by namespaced effect identifier.

equipment? ​

readonly optional equipment?: Readonly<Partial<Record<"mainhand" | "offhand" | "head" | "chest" | "legs" | "feet" | "body" | "saddle", ItemStack>>>

Defined in: world.ts:97

experienceLevel? ​

readonly optional experienceLevel?: number

Defined in: world.ts:115

Experience level, read by type_specific/player.

flags? ​

readonly optional flags?: 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? ​

readonly optional food?: FoodView

Defined in: world.ts:119

Hunger state, read by type_specific/player.

gameMode? ​

readonly optional gameMode?: string

Defined in: world.ts:117

Game mode identifier, read by type_specific/player.

lookingAt? ​

readonly optional lookingAt?: EntityView

Defined in: world.ts:103

The entity a player is looking at, read by type_specific/player.

movement? ​

readonly optional movement?: MovementView

Defined in: world.ts:111

movementAffectedBy? ​

readonly optional movementAffectedBy?: BlockState

Defined in: world.ts:110

The block the entity's movement is affected by, read by movement_affected_by.

nbt? ​

readonly optional nbt?: unknown

Defined in: world.ts:123

Parsed NBT for the nbt sub-predicate, in whatever shape the host uses.

passenger? ​

readonly optional passenger?: EntityView

Defined in: world.ts:99

position? ​

readonly optional position?: Vec3

Defined in: world.ts:91

scores? ​

readonly optional scores?: ReadonlyMap<string, number>

Defined in: world.ts:106

Scoreboard values, keyed by objective name.

steppingOn? ​

readonly optional steppingOn?: BlockState

Defined in: world.ts:108

The block under the entity's feet, read by stepping_on.

target? ​

readonly optional target?: EntityView

Defined in: world.ts:101

The entity this one is attacking, read by the targeted_entity sub-predicate.

team? ​

readonly optional team?: string

Defined in: world.ts:104

ticksExisted? ​

readonly optional ticksExisted?: number

Defined in: world.ts:113

Age in ticks, read by periodic_tick.

type ​

readonly type: string

Defined in: world.ts:88

Namespaced entity type identifier, for example minecraft:sheep.

typeSpecific? ​

readonly optional typeSpecific?: 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? ​

readonly optional typeTags?: readonly string[]

Defined in: world.ts:90

Entity type tags this entity belongs to, namespaced and without the leading #.

vehicle? ​

readonly optional vehicle?: EntityView

Defined in: world.ts:98


ExplorationMapRequest ​

Defined in: item.ts:100

What exploration_map is asked to find.

Properties ​

decoration ​

readonly decoration: string

Defined in: item.ts:104

Namespaced map decoration id.

destination ​

readonly destination: string

Defined in: item.ts:102

Namespaced structure id or tag the map should point at.

searchRadius ​

readonly searchRadius: number

Defined in: item.ts:106

skipExistingChunks ​

readonly skipExistingChunks: boolean

Defined in: item.ts:107

zoom ​

readonly zoom: 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 ​

readonly name: string

Defined in: world.ts:18

properties? ​

readonly optional properties?: 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 ​

readonly level: number

Defined in: world.ts:76

Food level, which runs from 0 to 20 in vanilla.

saturation ​

readonly saturation: 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? ​

readonly optional dataComponentPredicates?: Readonly<Record<string, SubPredicateParser<ItemStack>>>

Defined in: parse.ts:27

Extra data component predicate types, keyed by namespaced id.

entitySubPredicates? ​

readonly optional entitySubPredicates?: 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 ​

readonly components: ReadonlyMap<string, unknown>

Defined in: item.ts:14

Data components keyed by namespaced component type, for example minecraft:enchantments.

count ​

readonly count: number

Defined in: item.ts:10

id ​

readonly id: string

Defined in: item.ts:9

Namespaced item identifier, for example minecraft:diamond.

meta? ​

readonly optional meta?: 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 ​

ItemStack

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 ​

ItemStack

maxDamage() ​

maxDamage(stack): number

Defined in: item.ts:35

Durability of the item, or 0 when it takes no damage.

Parameters ​
stack ​

ItemStack

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 ​

ItemStack

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 ​

ItemStack

type ​

string

value ​

unknown

Returns ​

ItemStack

withCount() ​

withCount(stack, count): ItemStack

Defined in: item.ts:26

Parameters ​
stack ​

ItemStack

count ​

number

Returns ​

ItemStack

withId() ​

withId(stack, id): ItemStack

Defined in: item.ts:25

Parameters ​
stack ​

ItemStack

id ​

string

Returns ​

ItemStack

withMeta()? ​

optional withMeta(stack, meta): ItemStack

Defined in: item.ts:28

Sets Bedrock's auxiliary item data, or clears it when undefined.

Parameters ​
stack ​

ItemStack

meta ​

number | undefined

Returns ​

ItemStack


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()? ​

optional biomeAt(position): string | undefined

Defined in: world.ts:155

Namespaced biome identifier at a position.

Parameters ​
position ​

Vec3

Returns ​

string | undefined

biomeTagsAt()? ​

optional biomeTagsAt(position): readonly string[]

Defined in: world.ts:157

Biome tags the biome at a position belongs to, namespaced and without the leading #.

Parameters ​
position ​

Vec3

Returns ​

readonly string[]

blockAt()? ​

optional blockAt(position): BlockState | undefined

Defined in: world.ts:152

Parameters ​
position ​

Vec3

Returns ​

BlockState | undefined

canSeeSky()? ​

optional canSeeSky(position): boolean

Defined in: world.ts:162

Parameters ​
position ​

Vec3

Returns ​

boolean

clockTicks()? ​

optional clockTicks(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()? ​

optional dimension(): string

Defined in: world.ts:151

Namespaced dimension identifier of the level being evaluated.

Returns ​

string

environmentAttribute()? ​

optional environmentAttribute(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()? ​

optional fluidAt(position): FluidState | undefined

Defined in: world.ts:153

Parameters ​
position ​

Vec3

Returns ​

FluidState | undefined

isRaining()? ​

optional isRaining(): boolean

Defined in: world.ts:148

Returns ​

boolean

isSmokey()? ​

optional isSmokey(position): boolean

Defined in: world.ts:164

Whether a campfire below the position is producing smoke.

Parameters ​
position ​

Vec3

Returns ​

boolean

isThundering()? ​

optional isThundering(): boolean

Defined in: world.ts:149

Returns ​

boolean

lightAt()? ​

optional lightAt(position): number

Defined in: world.ts:161

Combined light level at a position, which is what Java's light predicate compares.

Parameters ​
position ​

Vec3

Returns ​

number

score()? ​

optional score(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()? ​

optional storedNumber(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()? ​

optional structuresAt(position): readonly string[]

Defined in: world.ts:159

Namespaced identifiers of the structures whose bounding box contains a position.

Parameters ​
position ​

Vec3

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? ​

optional additional_cost_component_allowed?: boolean

Defined in: context.ts:30

attacking_entity? ​

optional attacking_entity?: EntityView

Defined in: context.ts:20

The entity behind the damage, which is the shooter for a projectile.

block_entity? ​

optional block_entity?: BlockEntityView

Defined in: context.ts:25

block_state? ​

optional block_state?: BlockState

Defined in: context.ts:24

container? ​

optional container?: readonly ItemStack[]

Defined in: context.ts:31

damage_source? ​

optional damage_source?: DamageSource

Defined in: context.ts:18

direct_attacking_entity? ​

optional direct_attacking_entity?: EntityView

Defined in: context.ts:22

The entity that landed the hit, which is the projectile itself.

enchantment_active? ​

optional enchantment_active?: boolean

Defined in: context.ts:29

enchantment_level? ​

optional enchantment_level?: number

Defined in: context.ts:28

explosion_radius? ​

optional explosion_radius?: number

Defined in: context.ts:27

interacting_entity? ​

optional interacting_entity?: EntityView

Defined in: context.ts:15

last_damage_player? ​

optional last_damage_player?: EntityView

Defined in: context.ts:17

origin? ​

optional origin?: Vec3

Defined in: context.ts:23

target_entity? ​

optional target_entity?: EntityView

Defined in: context.ts:16

this_entity? ​

optional this_entity?: EntityView

Defined in: context.ts:14

The entity the evaluation is about: the mob that died, the player opening the chest.

tool? ​

optional tool?: 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 ​

readonly ids: ReadonlySet<string>

Defined in: reference.ts:103

tags ​

readonly tags: readonly string[]

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? ​

readonly optional fallDistance?: number

Defined in: world.ts:70

horizontalSpeed? ​

readonly optional horizontalSpeed?: number

Defined in: world.ts:68

speed? ​

readonly optional speed?: number

Defined in: world.ts:67

verticalSpeed? ​

readonly optional verticalSpeed?: number

Defined in: world.ts:69

x? ​

readonly optional x?: number

Defined in: world.ts:64

y? ​

readonly optional y?: number

Defined in: world.ts:65

z? ​

readonly optional z?: 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? ​

optional diagnostics?: DiagnosticCollector

Defined in: parse.ts:35

Reuse a collector to gather diagnostics from several parses into one report.

extensions? ​

optional extensions?: GrammarExtensions

Defined in: parse.ts:38

path? ​

optional path?: string

Defined in: parse.ts:37

Prefix for diagnostic paths, such as the file the JSON came from.

resolver? ​

optional resolver?: 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 ​

readonly diagnostics: readonly Diagnostic[]

Defined in: parse.ts:44

value ​

readonly value: 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? ​

optional content?: ContentView

Defined in: context.ts:129

diagnostics? ​

optional diagnostics?: DiagnosticCollector

Defined in: context.ts:126

Defaults to a fresh collector, reachable as PredicateContext.diagnostics.

enchantments? ​

optional enchantments?: EnchantmentView

Defined in: context.ts:128

items? ​

optional items?: ItemStackOps

Defined in: context.ts:127

level? ​

optional level?: LevelView

Defined in: context.ts:124

parameters? ​

optional parameters?: LootContextParameters

Defined in: context.ts:121

parameterSet? ​

optional parameterSet?: "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? ​

optional random?: 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()? ​

optional element(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()? ​

optional tag(registry, id): readonly string[] | undefined

Defined in: reference.ts:54

Returns the namespaced member ids of a tag, or undefined when the tag is unknown.

Parameters ​
registry ​

ReferenceRegistry

id ​

string

Returns ​

readonly string[] | undefined


SeededRandomState ​

Defined in: random.ts:14

JSON-safe state captured by seededRandom.

Properties ​

algorithm ​

readonly algorithm: "mulberry32"

Defined in: random.ts:16

state ​

readonly state: number

Defined in: random.ts:18

The generator's current unsigned 32-bit counter.

version ​

readonly version: 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 ​

RandomSource.nextFloat

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 ​

RandomSource.nextInt

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 ​

SeededRandomState


Vec3 ​

Defined in: world.ts:4

A position in world space.

Properties ​

x ​

readonly x: number

Defined in: world.ts:5

y ​

readonly y: number

Defined in: world.ts:6

z ​

readonly z: 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 ​

PredicateContext

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 ​

PredicateContext

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 ​

PredicateContext

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 ​

PredicateContext

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 ​

PredicateContext

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 ​

ItemStack

context ​

PredicateContext

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 ​

PredicateContext

block? ​

BlockState

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 ​

PredicateContext

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 ​

PredicateContext

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 ​

PredicateContext

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 ​

ParseContext

Returns ​

(subject, evaluation) => boolean

Variables ​

CONTEXT_PARAMETER_SETS ​

const CONTEXT_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 ​

readonly advancement_entity: object

advancement_entity.optional ​

readonly optional: readonly [] = []

advancement_entity.required ​

readonly required: readonly ["this_entity", "origin"]

advancement_location ​

readonly advancement_location: object

advancement_location.optional ​

readonly optional: readonly ["block_entity"]

advancement_location.required ​

readonly required: readonly ["this_entity", "origin", "tool", "block_state"]

advancement_reward ​

readonly advancement_reward: object

advancement_reward.optional ​

readonly optional: readonly [] = []

advancement_reward.required ​

readonly required: readonly ["this_entity", "origin"]

archaeology ​

readonly archaeology: object

archaeology.optional ​

readonly optional: readonly [] = []

archaeology.required ​

readonly required: readonly ["origin", "this_entity", "tool"]

barter ​

readonly barter: object

barter.optional ​

readonly optional: readonly [] = []

barter.required ​

readonly required: readonly ["this_entity"]

block ​

readonly block: object

block.optional ​

readonly optional: readonly ["this_entity", "block_entity", "explosion_radius"]

block.required ​

readonly required: readonly ["block_state", "origin", "tool"]

block_interact ​

readonly block_interact: object

block_interact.optional ​

readonly optional: readonly ["block_entity", "interacting_entity", "tool"]

block_interact.required ​

readonly required: readonly ["block_state", "origin"]

block_use ​

readonly block_use: object

block_use.optional ​

readonly optional: readonly [] = []

block_use.required ​

readonly required: readonly ["this_entity", "origin", "block_state"]

chest ​

readonly chest: object

chest.optional ​

readonly optional: readonly ["this_entity"]

chest.required ​

readonly required: readonly ["origin"]

command ​

readonly command: object

command.optional ​

readonly optional: readonly ["this_entity"]

command.required ​

readonly required: readonly ["origin"]

command_compute_default ​

readonly command_compute_default: object

command_compute_default.optional ​

readonly optional: readonly ["this_entity"]

command_compute_default.required ​

readonly required: readonly ["origin"]

command_compute_entity ​

readonly command_compute_entity: object

command_compute_entity.optional ​

readonly optional: readonly ["this_entity"]

command_compute_entity.required ​

readonly required: readonly ["origin", "target_entity"]

command_compute_position ​

readonly command_compute_position: object

command_compute_position.optional ​

readonly optional: readonly ["this_entity", "block_entity"]

command_compute_position.required ​

readonly required: readonly ["origin", "block_state"]

command_slot_source ​

readonly command_slot_source: object

command_slot_source.optional ​

readonly optional: readonly ["this_entity"]

command_slot_source.required ​

readonly required: readonly ["origin", "container"]

container_process ​

readonly container_process: object

container_process.optional ​

readonly optional: readonly [] = []

container_process.required ​

readonly required: readonly ["block_entity", "block_state", "container", "origin"]

empty ​

readonly empty: object

empty.optional ​

readonly optional: readonly [] = []

empty.required ​

readonly required: readonly [] = []

enchanted_damage ​

readonly enchanted_damage: object

enchanted_damage.optional ​

readonly optional: readonly ["direct_attacking_entity", "attacking_entity"]

enchanted_damage.required ​

readonly required: readonly ["this_entity", "enchantment_level", "origin", "damage_source"]

enchanted_entity ​

readonly enchanted_entity: object

enchanted_entity.optional ​

readonly optional: readonly [] = []

enchanted_entity.required ​

readonly required: readonly ["this_entity", "enchantment_level", "origin"]

enchanted_item ​

readonly enchanted_item: object

enchanted_item.optional ​

readonly optional: readonly [] = []

enchanted_item.required ​

readonly required: readonly ["tool", "enchantment_level"]

enchanted_location ​

readonly enchanted_location: object

enchanted_location.optional ​

readonly optional: readonly [] = []

enchanted_location.required ​

readonly required: readonly ["this_entity", "enchantment_level", "origin", "enchantment_active"]

entity ​

readonly entity: object

entity.optional ​

readonly optional: readonly ["attacking_entity", "direct_attacking_entity", "last_damage_player"]

entity.required ​

readonly required: readonly ["this_entity", "origin", "damage_source"]

entity_interact ​

readonly entity_interact: object

entity_interact.optional ​

readonly optional: readonly ["interacting_entity"]

entity_interact.required ​

readonly required: readonly ["target_entity", "tool"]

equipment ​

readonly equipment: object

equipment.optional ​

readonly optional: readonly [] = []

equipment.required ​

readonly required: readonly ["origin", "this_entity"]

fishing ​

readonly fishing: object

fishing.optional ​

readonly optional: readonly ["this_entity"]

fishing.required ​

readonly required: readonly ["origin", "tool"]

generic ​

readonly generic: object

generic.optional ​

readonly optional: readonly [] = []

generic.required ​

readonly required: readonly ["this_entity", "last_damage_player", "damage_source", "attacking_entity", "direct_attacking_entity", "origin", "block_state"]

gift ​

readonly gift: object

gift.optional ​

readonly optional: readonly [] = []

gift.required ​

readonly required: readonly ["origin", "this_entity"]

hit_block ​

readonly hit_block: object

hit_block.optional ​

readonly optional: readonly [] = []

hit_block.required ​

readonly required: readonly ["this_entity", "enchantment_level", "origin", "block_state"]

selector ​

readonly selector: object

selector.optional ​

readonly optional: readonly [] = []

selector.required ​

readonly required: readonly ["origin", "this_entity"]

shearing ​

readonly shearing: object

shearing.optional ​

readonly optional: readonly [] = []

shearing.required ​

readonly required: readonly ["origin", "this_entity", "tool"]

vault ​

readonly vault: object

vault.optional ​

readonly optional: readonly ["this_entity"]

vault.required ​

readonly required: readonly ["origin", "tool"]

villager_trade ​

readonly villager_trade: object

villager_trade.optional ​

readonly optional: readonly [] = []

villager_trade.required ​

readonly required: readonly ["origin", "this_entity", "additional_cost_component_allowed"]


DATA_COMPONENT_PREDICATES ​

const DATA_COMPONENT_PREDICATES: readonly string[] = DATA_COMPONENT_PREDICATE_TYPES

Defined in: subpredicates.ts:153

The 15 data component predicate types Java 26.3 registers.


ELEMENT_REGISTRIES ​

const ELEMENT_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 ​

const ENTITY_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 ​

const ENTITY_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 ​

const ENTITY_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 ​

readonly attacker: "attacking_entity" = 'attacking_entity'

attacking_player ​

readonly attacking_player: "last_damage_player" = 'last_damage_player'

direct_attacker ​

readonly direct_attacker: "direct_attacking_entity" = 'direct_attacking_entity'

interacting_entity ​

readonly interacting_entity: "interacting_entity" = 'interacting_entity'

target_entity ​

readonly target_entity: "target_entity" = 'target_entity'

this ​

readonly this: "this_entity" = 'this_entity'


EQUIPMENT_SLOTS ​

const EQUIPMENT_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 ​

const ID_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 ​

const LOOT_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 ​

const LOOT_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 ​

const defaultEnchantmentView: EnchantmentView

Defined in: item.ts:130

An EnchantmentView that only knows what the stack's own components say.


defaultItemStackOps ​

const defaultItemStackOps: 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): readonly unknown[]

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): readonly unknown[]

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 ​

ParseContext

Returns ​

BlockMatcher


constantRandom() ​

constantRandom(value): RandomSource

Defined in: random.ts:59

A source that always draws the same float.

Parameters ​

value ​

number

Returns ​

RandomSource


damageSourcePredicate() ​

damageSourcePredicate(value, context): DamageSourceMatcher

Defined in: subpredicates.ts:711

Parses Java's DamageSourcePredicate.

Parameters ​

value ​

unknown

context ​

ParseContext

Returns ​

DamageSourceMatcher


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 ​

ItemStack

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 ​

ParseContext

Returns ​

EntityMatcher


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 ​

ParseContext

Returns ​

NumberProvider


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 ​

ParseContext

Returns ​

RangeTest


fluidPredicate() ​

fluidPredicate(value, context): FluidMatcher

Defined in: subpredicates.ts:291

Parses Java's FluidPredicate.

Parameters ​

value ​

unknown

context ​

ParseContext

Returns ​

FluidMatcher


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 ​

ParseContext

Returns ​

NumberProvider


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 ​

ParseContext

Returns ​

RangeTest


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 ​

RandomSource

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 ​

ParseContext

Returns ​

ItemMatcher


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 ​

ParseContext

Returns ​

LevelBasedValue


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 ​

ParseContext

Returns ​

LocationMatcher


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 ​

ParseContext

Returns ​

ItemModifier


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 ​

ParseContext

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 ​

ParseContext

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? ​

ParseOptions

Returns ​

ParseResult<NumberProvider>


parseIntProvider() ​

parseIntProvider(value, options?): ParseResult<NumberProvider>

Defined in: providers.ts:381

Compiles an int provider from parsed JSON.

Parameters ​

value ​

unknown

options? ​

ParseOptions

Returns ​

ParseResult<NumberProvider>


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? ​

ParseOptions

Returns ​

ParseResult<ItemModifier>


parseLevelBasedValue() ​

parseLevelBasedValue(value, options?): ParseResult<LevelBasedValue>

Defined in: providers.ts:393

Compiles an enchantment level based value from parsed JSON.

Parameters ​

value ​

unknown

options? ​

ParseOptions

Returns ​

ParseResult<LevelBasedValue>


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? ​

ParseOptions

Returns ​

ParseResult<Predicate>


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 ​

ParseContext

Returns ​

Predicate


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 ​

ReferenceRegistry

context ​

ParseContext

Returns ​

MemberSet


rootContext() ​

rootContext(options?): ParseContext

Defined in: parse.ts:102

Builds the root parse context from caller options.

Parameters ​

options? ​

ParseOptions = {}

Returns ​

ParseContext


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 ​

RandomSource


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 ​

StatefulRandomSource


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 ​

ParseContext

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 ​

PredicateContext

target ​

"interacting_entity" | "target_entity" | "this" | "attacker" | "direct_attacker" | "attacking_player"

path ​

string

Returns ​

EntityView | undefined