Skip to content

API reference / @jsprismarine/advancements

@jsprismarine/advancements ​

The Java Edition advancement engine. It parses advancement files once, links them into the parent tree, routes game events to the criteria listening for them, keeps per-player progress, and fires rewards through hooks a host supplies.

Conditions are not reimplemented here. Every entity, item, block, location, damage and fluid check inside a criterion is a loot condition compiled by @jsprismarine/predicates, which also owns 26.3's inline-or-id-or-list-or-tag composition rule. This package adds the 58 trigger types that the predicate package explicitly leaves out.

The grammar was read out of the Java 26.3 server jar: minecraft:trigger_type in reports/registries.json for the 58 ids, and the TriggerInstance records under net/minecraft/advancements/triggers/ for each one's fields. Parsing never throws; faults land in a DiagnosticCollector from the predicate package.

Install ​

bash
pnpm add @jsprismarine/advancements

Using it ​

typescript
import { AdvancementEngine, PlayerAdvancements, parseAdvancement } from '@jsprismarine/advancements';

const engine = new AdvancementEngine({
    rewards: {
        grantExperience: (player, amount) => player.addExperience(amount),
        unlockRecipe: (player, recipe) => player.recipeBook.unlock(recipe)
    }
});

engine.load(
    [...definitions.advancements].flatMap(([id, json]) => {
        const { value } = parseAdvancement(id, json, { resolver });
        return value ? [value] : [];
    })
);

const progress = new PlayerAdvancements();
const completed = engine.raise('placed_block', { player, origin, blockState, tool }, progress);

definitions.advancements is what @jsprismarine/packs produces for a pack stack: the 1866 vanilla advancement files plus whatever the loaded datapacks add. resolver is the same ReferenceResolver the predicate package takes, and it is what lets a #tag inside a criterion or in rewards.loot expand.

The model ​

parseAdvancement(id, json, options) returns { value, diagnostics }, with value undefined only when the file has no usable criterion. The parsed shape follows the 26.3 file:

FieldShapeDefault
parentnamespaced idabsent, which makes the advancement a root
displayicon, title, description, background, frame, showToast, announceToChat, hiddenabsent; frame is task, the two announcement flags are true, hidden is false
criteriamap from name to a trigger id and its compiled conditionsrequired and non-empty
requirementsarray of arrays of criterion namesone single-name group per criterion
rewardsexperience, lootTables, recipes, functionall empty
sendsTelemetryEventbooleanfalse

requirements is conjunctive normal form: every group must hold at least one completed criterion. The default that Java's AdvancementRequirements.allOf produces is therefore an and over all criteria, and a single-criterion file completes on that one criterion. Parsing reports a group that names no criterion of the file, a criterion that appears in no group, and an empty group.

buildAdvancementTree(advancements) resolves each parent into an AdvancementNode with its children. A parent that was not loaded reports and leaves the node a root. A parent chain that closes on itself reports at the first node whose walk revisits an id and detaches that node, which breaks the cycle and keeps the rest of the chain linked.

Titles and descriptions stay as parsed JSON. Turning a chat component into text belongs to the text layer, and the engine never reads them.

Triggers and coverage ​

All 58 registered types are implemented. Java spreads them over 29 TriggerInstance shapes, so the ids that read the same JSON share one parser here as well. Counts below are criteria across the 1866 vanilla files, measured by corpus.test.ts.

TriggerVanilla criteriaEvent
inventory_changed1914InventoryEvent
recipe_unlocked1739RecipeEvent
player_killed_entity89KillEvent
location67PlayerEvent
consume_item41ItemEvent
recipe_crafted27RecipeCraftedEvent
bred_animals27BredAnimalsEvent
tame_animal21EntityEvent
placed_block15ItemUsedOnBlockEvent
enter_block12BlockEvent
item_used_on_block10ItemUsedOnBlockEvent
player_generates_container_loot10ContainerLootEvent
player_interacted_with_entity8PlayerInteractEvent
filled_bucket6ItemEvent
changed_dimension4ChangedDimensionEvent
fishing_rod_hooked4FishingRodHookedEvent
using_item, summoned_entity, player_hurt_entity, killed_by_arrow, effects_changed3 eachsee events.ts
villager_trade, thrown_item_picked_up_by_entity, construct_beacon2 each
30 further triggers1 each
used_ender_eye, voluntary_exile, default_block_use, any_block_use0implemented, unused by vanilla

54 of the 58 appear in vanilla and 30 of those appear exactly once. The four with no vanilla criterion are implemented anyway, because a datapack can use them.

Three triggers need a note.

inventory_changed splits on how many item predicates it holds. Java tests a single predicate against the stack that changed and a list of several against the whole inventory, removing each predicate as a stack satisfies it. 1913 of the 1914 vanilla criteria take the single-predicate path, so InventoryEvent carries both inventory and changed. The slots counts are computed only when a criterion declares the field, which one vanilla criterion does.

killed_by_arrow needs a distinct victim per condition, channeled_lightning does not. Java removes a matched victim from the list in the first and not in the second, and the two behave differently when two conditions could match the same entity.

brewed_potion's potion field is a PotionsPredicate, which is 26.3's minecraft:potion_contents data component predicate. Rather than fork the component grammar, this package wraps the field into an item predicate and evaluates it against the brewed stack. The predicate package does not implement potion_contents yet, so such a field warns and evaluates false. No vanilla advancement writes it.

The event bus seam ​

engine.raise(trigger, event, progress) is the whole seam. TriggerEvents maps each trigger id to the event shape it listens for, so passing a BlockEvent to placed_block is a compile error. The engine builds the loot context each condition needs: advancement_entity for the player field and every other entity field, advancement_location for the location field of the placed_block family, and block_use for default_block_use and any_block_use.

Criteria are indexed by trigger, so an event touches only the criteria registered under it. The four triggers whose event names one registry element are indexed by that element as well:

TriggerIndexed by
recipe_unlockedeach id in recipes
recipe_craftedeach id in recipes
crafter_recipe_craftedeach id in recipes
player_generates_container_looteach id in loot_tables

The number that decides the cost is how many criteria one event evaluates, and engine.test.ts asserts it by counting draws from an injected random source. Against the whole vanilla corpus of 1866 advancements and 4045 criteria:

  • recipe_unlocked evaluates 1 criterion, not the 1739 that use the trigger. Raising all 1739 unlocks takes 8 to 30 ms on an Apple silicon laptop under Node 24, so 5 to 17 us per event.
  • inventory_changed evaluates all 1914 criteria in its bucket, because no field of that trigger names a registry element to key on. One event takes 280 to 1140 us on the same machine, so roughly 0.15 to 0.6 us per criterion. This is the engine's worst dispatch.

Both wall-clock ranges come from repeated runs on a machine that was also building other packages, which is where the spread comes from; the criterion counts are exact.

Within one raise the engine builds each entity's predicate context once and reuses it, which is what keeps the per-criterion cost of the big bucket under a microsecond.

Progress ​

PlayerAdvancements is the per-player store. The engine takes one as an argument rather than owning it, so a server keeps progress wherever it keeps the rest of a player's data.

typescript
progress.grant('minecraft:story/mine_stone', 'get_stone');
progress.hasCriterion('minecraft:story/mine_stone', 'get_stone'); // true
progress.isDone(engine.get('minecraft:story/mine_stone')!); // true
progress.revokeCriterion('minecraft:story/mine_stone', 'get_stone');
progress.revoke('minecraft:story/mine_stone');

toJSON produces a plain object a server can persist as is, and fromJSON reads it back:

json
{
    "minecraft:story/mine_stone": {
        "criteria": { "get_stone": "2026-10-25T09:14:02.511Z" },
        "done": true
    }
}

Instants are ISO-8601 rather than Java's yyyy-MM-dd HH:mm:ss Z, because nothing here reads a Java player data file and Date.parse round-trips ISO-8601 without a format string. grant takes an explicit instant, so a test or a migration decides its own clock.

fromJSON ignores the stored done flag and recomputes completion from the advancement's current requirements. A datapack reload that changes requirements therefore re-derives whether a player has finished, instead of trusting a flag written against the old matrix.

Reward hooks ​

Every hook is optional, and a reward with no hook reports a warning instead of failing the completion, so a server can ship advancements before it has every subsystem.

typescript
new AdvancementEngine({
    rewards: {
        grantExperience: (player, amount) => {},
        runLootTable: (player, lootTable) => {},
        unlockRecipe: (player, recipe) => {},
        runFunction: (player, id) => {}
    }
});

runFunction is the seam @jsprismarine/mcfunction fills; nothing in this package depends on it. Rewards fire once, when the advancement completes, from either raise or award. Vanilla uses recipes on 1739 files and experience on 23, and uses neither loot nor function.

Corpus test ​

corpus.test.ts parses the real Java 26.3 vanilla advancements out of the cached server jar and asserts the grammar reports nothing, neither errors nor warnings. It measures 1866 files, 4045 criteria, 54 used triggers, 6 roots and no parent cycle, and it pins the per-trigger counts in the table above. 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 ​

AdvancementDisplay ​

Defined in: model.ts:34

What a client draws for an advancement in the tab and in the toast.

Properties ​

announceToChat ​

readonly announceToChat: boolean

Defined in: model.ts:43

background? ​

readonly optional background?: string

Defined in: model.ts:40

Background texture of a root advancement's tab, absent on every non-root.

description ​

readonly description: unknown

Defined in: model.ts:38

frame ​

readonly frame: "task" | "challenge" | "goal"

Defined in: model.ts:41

hidden ​

readonly hidden: boolean

Defined in: model.ts:44

icon ​

readonly icon: AdvancementIcon

Defined in: model.ts:35

showToast ​

readonly showToast: boolean

Defined in: model.ts:42

title ​

readonly title: unknown

Defined in: model.ts:37

Chat component JSON; turning it into text belongs to the text package, not here.


AdvancementEngineOptions ​

Defined in: engine.ts:36

The world views and hooks an engine evaluates and rewards through.

Properties ​

content? ​

optional content?: ContentView

Defined in: engine.ts:40

diagnostics? ​

optional diagnostics?: DiagnosticCollector

Defined in: engine.ts:43

Reuse a collector to gather load faults and evaluation faults into one report.

enchantments? ​

optional enchantments?: EnchantmentView

Defined in: engine.ts:39

items? ​

optional items?: ItemStackOps

Defined in: engine.ts:38

level? ​

optional level?: LevelView

Defined in: engine.ts:37

random? ​

optional random?: RandomSource

Defined in: engine.ts:41

rewards? ​

optional rewards?: RewardHooks

Defined in: engine.ts:44


AdvancementIcon ​

Defined in: model.ts:25

The stack template an advancement draws as its icon.

Properties ​

components? ​

readonly optional components?: unknown

Defined in: model.ts:30

Data components as parsed JSON, because only the client reads them.

count ​

readonly count: number

Defined in: model.ts:28

id ​

readonly id: string

Defined in: model.ts:27

Namespaced item identifier.


AdvancementNode ​

Defined in: tree.ts:7

One advancement in the tree, with its resolved parent and children.

Properties ​

advancement ​

readonly advancement: ParsedAdvancement

Defined in: tree.ts:9

children ​

readonly children: readonly AdvancementNode[]

Defined in: tree.ts:12

id ​

readonly id: string

Defined in: tree.ts:8

parent? ​

readonly optional parent?: AdvancementNode

Defined in: tree.ts:11

Absent on a root, and on a node whose parent could not be resolved.


AdvancementProgressJson ​

Defined in: progress.ts:22

One advancement's stored progress, as a server persists it.

Properties ​

criteria ​

readonly criteria: Readonly<Record<string, string>>

Defined in: progress.ts:24

Criterion name to the ISO-8601 instant it was completed at.

done ​

readonly done: boolean

Defined in: progress.ts:25


AdvancementProgressView ​

Defined in: progress.ts:32

How far a player is through one advancement.

Properties ​

completed ​

readonly completed: number

Defined in: progress.ts:37

Satisfied requirement groups out of the advancement's total.

criteria ​

readonly criteria: ReadonlyMap<string, string>

Defined in: progress.ts:34

Completed criterion names with the instant each was completed at.

done ​

readonly done: boolean

Defined in: progress.ts:35

total ​

readonly total: number

Defined in: progress.ts:38


AdvancementRewards ​

Defined in: model.ts:48

What completing an advancement hands the player.

Properties ​

experience ​

readonly experience: number

Defined in: model.ts:49

function? ​

readonly optional function?: string

Defined in: model.ts:55

Namespaced identifier of an mcfunction to run.

lootTables ​

readonly lootTables: readonly string[]

Defined in: model.ts:51

Namespaced loot table identifiers, with any #tag already expanded.

recipes ​

readonly recipes: readonly string[]

Defined in: model.ts:53

Namespaced recipe identifiers to unlock.


AdvancementTree ​

Defined in: tree.ts:16

Every advancement, linked by parent.

Properties ​

nodes ​

readonly nodes: ReadonlyMap<string, AdvancementNode>

Defined in: tree.ts:19

roots ​

readonly roots: readonly AdvancementNode[]

Defined in: tree.ts:18

Nodes with no parent, in the order the advancements were given.


BeaconEvent ​

Defined in: events.ts:96

A beacon the player completed.

Extends ​

Properties ​

level ​

readonly level: number

Defined in: events.ts:98

Number of complete pyramid layers under the beacon.

player ​

readonly player: EntityView

Defined in: events.ts:22

Inherited from ​

PlayerEvent.player


BeeNestDestroyedEvent ​

Defined in: events.ts:208

A bee nest or beehive the player broke.

Extends ​

Properties ​

beesInside ​

readonly beesInside: number

Defined in: events.ts:212

blockState ​

readonly blockState: BlockState

Defined in: events.ts:209

item ​

readonly item: ItemStack

Defined in: events.ts:211

The stack used to break it.

player ​

readonly player: EntityView

Defined in: events.ts:22

Inherited from ​

PlayerEvent.player


BlockEvent ​

Defined in: events.ts:37

A block a player entered or slid down.

Extends ​

Properties ​

blockState ​

readonly blockState: BlockState

Defined in: events.ts:38

player ​

readonly player: EntityView

Defined in: events.ts:22

Inherited from ​

PlayerEvent.player


BlockInteractionEvent ​

Defined in: events.ts:162

A block the player right-clicked, without the item in hand.

Extends ​

Properties ​

blockState ​

readonly blockState: BlockState

Defined in: events.ts:164

origin ​

readonly origin: Vec3

Defined in: events.ts:163

player ​

readonly player: EntityView

Defined in: events.ts:22

Inherited from ​

PlayerEvent.player


BredAnimalsEvent ​

Defined in: events.ts:108

Two animals that bred.

Extends ​

Properties ​

child? ​

readonly optional child?: EntityView

Defined in: events.ts:112

Absent when the breeding produced no child, as mule breeding can.

parent ​

readonly parent: EntityView

Defined in: events.ts:109

partner ​

readonly partner: EntityView

Defined in: events.ts:110

player ​

readonly player: EntityView

Defined in: events.ts:22

Inherited from ​

PlayerEvent.player


BrewedPotionEvent ​

Defined in: events.ts:90

A potion a brewing stand finished for the player.

Extends ​

Properties ​

player ​

readonly player: EntityView

Defined in: events.ts:22

Inherited from ​

PlayerEvent.player

potion ​

readonly potion: ItemStack

Defined in: events.ts:92

The brewed stack, whose minecraft:potion_contents the potion field reads.


ChangedDimensionEvent ​

Defined in: events.ts:145

A dimension change.

Extends ​

Properties ​

from ​

readonly from: string

Defined in: events.ts:147

Namespaced dimension identifier the player left.

player ​

readonly player: EntityView

Defined in: events.ts:22

Inherited from ​

PlayerEvent.player

to ​

readonly to: string

Defined in: events.ts:149

Namespaced dimension identifier the player arrived in.


CompiledCriterion ​

Defined in: model.ts:64

One compiled criterion. test declares the union of every event shape because compiling erases which trigger produced it; the engine only ever calls it with the event its own trigger declares, and method syntax is what makes that assignment typecheck.

Properties ​

keys? ​

readonly optional keys?: readonly string[]

Defined in: model.ts:72

Registry ids this criterion can match, for the triggers KEYED_TRIGGERS covers. The engine indexes by them instead of putting the criterion in its trigger's linear bucket.

name ​

readonly name: string

Defined in: model.ts:65

trigger ​

readonly trigger: "villager_trade" | "enchanted_item" | "impossible" | "player_killed_entity" | "entity_killed_player" | "enter_block" | "inventory_changed" | "recipe_unlocked" | "player_hurt_entity" | "entity_hurt_player" | "filled_bucket" | "brewed_potion" | "construct_beacon" | "used_ender_eye" | "summoned_entity" | "bred_animals" | "location" | "slept_in_bed" | "cured_zombie_villager" | "item_durability_changed" | "levitation" | "changed_dimension" | "tick" | "tame_animal" | "placed_block" | "consume_item" | "effects_changed" | "used_totem" | "nether_travel" | "fishing_rod_hooked" | "channeled_lightning" | "shot_crossbow" | "spear_mobs" | "killed_by_arrow" | "hero_of_the_village" | "voluntary_exile" | "slide_down_block" | "bee_nest_destroyed" | "target_hit" | "item_used_on_block" | "default_block_use" | "any_block_use" | "player_generates_container_loot" | "thrown_item_picked_up_by_entity" | "thrown_item_picked_up_by_player" | "player_interacted_with_entity" | "player_sheared_equipment" | "started_riding" | "lightning_strike" | "using_item" | "fall_from_height" | "ride_entity_in_lava" | "kill_mob_near_sculk_catalyst" | "allay_drop_item_on_block" | "avoid_vibration" | "recipe_crafted" | "crafter_recipe_crafted" | "fall_after_explosion"

Defined in: model.ts:66

Methods ​

test() ​

test(event, services): boolean

Defined in: model.ts:73

Parameters ​
event ​

AnyTriggerEvent

services ​

EvaluationServices

Returns ​

boolean


ContainerLootEvent ​

Defined in: events.ts:223

A container whose loot the player generated.

Extends ​

Properties ​

lootTable ​

readonly lootTable: string

Defined in: events.ts:225

Namespaced loot table identifier.

player ​

readonly player: EntityView

Defined in: events.ts:22

Inherited from ​

PlayerEvent.player


CuredZombieVillagerEvent ​

Defined in: events.ts:116

A zombie villager a player cured.

Extends ​

Properties ​

player ​

readonly player: EntityView

Defined in: events.ts:22

Inherited from ​

PlayerEvent.player

villager ​

readonly villager: EntityView

Defined in: events.ts:118

zombie ​

readonly zombie: EntityView

Defined in: events.ts:117


DamageEvent ​

Defined in: events.ts:64

Damage the player took.

Extends ​

Extended by ​

Properties ​

blocked ​

readonly blocked: boolean

Defined in: events.ts:70

damageSource ​

readonly damageSource: DamageSource

Defined in: events.ts:65

dealt ​

readonly dealt: number

Defined in: events.ts:67

Damage before armor, resistance and enchantments reduced it.

player ​

readonly player: EntityView

Defined in: events.ts:22

Inherited from ​

PlayerEvent.player

taken ​

readonly taken: number

Defined in: events.ts:69

Damage that reached the health bar.


EffectsChangedEvent ​

Defined in: events.ts:168

A change to the player's status effects.

Extends ​

Properties ​

player ​

readonly player: EntityView

Defined in: events.ts:22

Inherited from ​

PlayerEvent.player

source? ​

readonly optional source?: EntityView

Defined in: events.ts:170

The entity that applied the effect, such as the shooter of a tipped arrow.


EnchantedItemEvent ​

Defined in: events.ts:84

An item that came out of an enchanting table.

Extends ​

Properties ​

item ​

readonly item: ItemStack

Defined in: events.ts:80

Inherited from ​

ItemEvent.item

levels ​

readonly levels: number

Defined in: events.ts:86

Experience levels the enchantment cost.

player ​

readonly player: EntityView

Defined in: events.ts:22

Inherited from ​

ItemEvent.player


EnderEyeEvent ​

Defined in: events.ts:102

An eye of ender thrown toward a stronghold.

Extends ​

Properties ​

distance ​

readonly distance: number

Defined in: events.ts:104

Horizontal distance in blocks from the player to the stronghold.

player ​

readonly player: EntityView

Defined in: events.ts:22

Inherited from ​

PlayerEvent.player


EntityEvent ​

Defined in: events.ts:26

An event about one other entity, such as the animal a player tamed.

Extends ​

Extended by ​

Properties ​

entity ​

readonly entity: EntityView

Defined in: events.ts:27

player ​

readonly player: EntityView

Defined in: events.ts:22

Inherited from ​

PlayerEvent.player


EvaluationServices ​

Defined in: events.ts:254

The world-facing views a trigger needs while it evaluates its conditions. Every member except the collector is optional and mirrors the matching seam on @jsprismarine/predicates; a condition that reaches a view the host left out reports a diagnostic and evaluates false.

Properties ​

content? ​

readonly optional content?: ContentView

Defined in: events.ts:259

contexts? ​

readonly optional contexts?: Map<EntityView, PredicateContext>

Defined in: events.ts:269

Memo for entityContext, which the engine refreshes for each event it raises. One event reaches every criterion registered under its trigger, and the biggest vanilla bucket holds 1914 of them, so building the player's context once instead of once per criterion is the difference the memo makes. Leave it out and each call builds a fresh context.

diagnostics ​

readonly diagnostics: DiagnosticCollector

Defined in: events.ts:255

enchantments? ​

readonly optional enchantments?: EnchantmentView

Defined in: events.ts:258

items? ​

readonly optional items?: ItemStackOps

Defined in: events.ts:257

level? ​

readonly optional level?: LevelView

Defined in: events.ts:256

random? ​

readonly optional random?: RandomSource

Defined in: events.ts:260


FallAfterExplosionEvent ​

Defined in: events.ts:179

A fall that an explosion started.

Extends ​

Properties ​

cause? ​

readonly optional cause?: EntityView

Defined in: events.ts:180

player ​

readonly player: EntityView

Defined in: events.ts:22

Inherited from ​

TravelEvent.player

startPosition ​

readonly startPosition: Vec3

Defined in: events.ts:175

Inherited from ​

TravelEvent.startPosition


FishingRodHookedEvent ​

Defined in: events.ts:184

A fishing bobber that caught something.

Extends ​

Properties ​

entity? ​

readonly optional entity?: EntityView

Defined in: events.ts:187

The hooked entity, absent when the bobber caught loot out of open water.

items ​

readonly items: readonly ItemStack[]

Defined in: events.ts:189

The stacks the catch produced.

player ​

readonly player: EntityView

Defined in: events.ts:22

Inherited from ​

PlayerEvent.player

rod ​

readonly rod: ItemStack

Defined in: events.ts:185


InventoryEvent ​

Defined in: events.ts:45

An inventory change. Java tests a single-item criterion against changed alone and a multi-item one against the whole inventory, so both are here.

Extends ​

Properties ​

changed? ​

readonly optional changed?: ItemStack

Defined in: events.ts:49

The stack that changed, or undefined when the change emptied the slot.

inventory ​

readonly inventory: readonly (ItemStack | undefined)[]

Defined in: events.ts:47

Every slot in order, with an empty slot as undefined.

player ​

readonly player: EntityView

Defined in: events.ts:22

Inherited from ​

PlayerEvent.player


ItemDurabilityEvent ​

Defined in: events.ts:129

Durability a tool lost or regained.

Extends ​

Properties ​

delta ​

readonly delta: number

Defined in: events.ts:133

Durability lost, negative when the item was repaired.

durability ​

readonly durability: number

Defined in: events.ts:131

Durability left after the change.

item ​

readonly item: ItemStack

Defined in: events.ts:80

Inherited from ​

ItemEvent.item

player ​

readonly player: EntityView

Defined in: events.ts:22

Inherited from ​

ItemEvent.player


ItemEvent ​

Defined in: events.ts:79

An event about one stack, such as the item a player ate.

Extends ​

Extended by ​

Properties ​

item ​

readonly item: ItemStack

Defined in: events.ts:80

player ​

readonly player: EntityView

Defined in: events.ts:22

Inherited from ​

PlayerEvent.player


ItemUsedOnBlockEvent ​

Defined in: events.ts:153

An item used against a block, which is also how a placed block is reported.

Extends ​

Properties ​

blockEntity? ​

readonly optional blockEntity?: BlockEntityView

Defined in: events.ts:158

blockState ​

readonly blockState: BlockState

Defined in: events.ts:155

origin ​

readonly origin: Vec3

Defined in: events.ts:154

player ​

readonly player: EntityView

Defined in: events.ts:22

Inherited from ​

PlayerEvent.player

tool ​

readonly tool: ItemStack

Defined in: events.ts:157

The stack in hand, which the match_tool condition reads.


KillEvent ​

Defined in: events.ts:31

A death, raised once for the killer and once for the victim.

Extends ​

Properties ​

damageSource? ​

readonly optional damageSource?: DamageSource

Defined in: events.ts:33

The blow that killed, read by player_killed_entity's killing_blow.

entity ​

readonly entity: EntityView

Defined in: events.ts:27

Inherited from ​

EntityEvent.entity

player ​

readonly player: EntityView

Defined in: events.ts:22

Inherited from ​

EntityEvent.player


KilledByArrowEvent ​

Defined in: events.ts:198

Entities killed by one arrow.

Extends ​

Properties ​

firedFromWeapon? ​

readonly optional firedFromWeapon?: ItemStack

Defined in: events.ts:199

player ​

readonly player: EntityView

Defined in: events.ts:22

Inherited from ​

VictimsEvent.player

victims ​

readonly victims: readonly EntityView[]

Defined in: events.ts:194

Inherited from ​

VictimsEvent.victims


LevitationEvent ​

Defined in: events.ts:137

A player carried upward by levitation.

Extends ​

Properties ​

duration ​

readonly duration: number

Defined in: events.ts:141

Remaining effect duration in ticks.

player ​

readonly player: EntityView

Defined in: events.ts:22

Inherited from ​

PlayerEvent.player

startPosition ​

readonly startPosition: Vec3

Defined in: events.ts:139

Where the levitation started, which the distance field measures from.


LightningStrikeEvent ​

Defined in: events.ts:242

A lightning bolt that struck near the player.

Extends ​

Properties ​

bystanders ​

readonly bystanders: readonly EntityView[]

Defined in: events.ts:245

Every entity within range of the strike.

lightning ​

readonly lightning: EntityView

Defined in: events.ts:243

player ​

readonly player: EntityView

Defined in: events.ts:22

Inherited from ​

PlayerEvent.player


ParsedAdvancement ​

Defined in: model.ts:77

One advancement file, parsed once and compiled.

Properties ​

criteria ​

readonly criteria: ReadonlyMap<string, CompiledCriterion>

Defined in: model.ts:84

display? ​

readonly optional display?: AdvancementDisplay

Defined in: model.ts:82

id ​

readonly id: string

Defined in: model.ts:79

Namespaced identifier, which is the file path under data/<namespace>/advancement/.

parent? ​

readonly optional parent?: string

Defined in: model.ts:81

Namespaced identifier of the parent, absent on a root.

requirements ​

readonly requirements: readonly (readonly string[])[]

Defined in: model.ts:91

Conjunctive normal form over the criterion names: the advancement completes when every group has at least one completed criterion. An absent requirements becomes one single-name group per criterion, which is Java's AdvancementRequirements.allOf.

rewards ​

readonly rewards: AdvancementRewards

Defined in: model.ts:83

sendsTelemetryEvent ​

readonly sendsTelemetryEvent: boolean

Defined in: model.ts:92


PickedUpItemEvent ​

Defined in: events.ts:229

A thrown item picked up, raised for the thrower and for the receiver.

Extends ​

Properties ​

entity? ​

readonly optional entity?: EntityView

Defined in: events.ts:232

The other party: the entity that picked the item up, or the one that threw it.

item ​

readonly item: ItemStack

Defined in: events.ts:230

player ​

readonly player: EntityView

Defined in: events.ts:22

Inherited from ​

PlayerEvent.player


PlayerEvent ​

Defined in: events.ts:21

What every advancement event carries. player is the subject of the player field that all 57 non-impossible triggers accept.

Extended by ​

Properties ​

player ​

readonly player: EntityView

Defined in: events.ts:22


PlayerHurtEntityEvent ​

Defined in: events.ts:74

Damage the player dealt to another entity.

Extends ​

Properties ​

blocked ​

readonly blocked: boolean

Defined in: events.ts:70

Inherited from ​

DamageEvent.blocked

damageSource ​

readonly damageSource: DamageSource

Defined in: events.ts:65

Inherited from ​

DamageEvent.damageSource

dealt ​

readonly dealt: number

Defined in: events.ts:67

Damage before armor, resistance and enchantments reduced it.

Inherited from ​

DamageEvent.dealt

entity ​

readonly entity: EntityView

Defined in: events.ts:75

player ​

readonly player: EntityView

Defined in: events.ts:22

Inherited from ​

DamageEvent.player

taken ​

readonly taken: number

Defined in: events.ts:69

Damage that reached the health bar.

Inherited from ​

DamageEvent.taken


PlayerInteractEvent ​

Defined in: events.ts:236

A player interacting with an entity using the item in hand.

Extends ​

Properties ​

entity ​

readonly entity: EntityView

Defined in: events.ts:238

item ​

readonly item: ItemStack

Defined in: events.ts:237

player ​

readonly player: EntityView

Defined in: events.ts:22

Inherited from ​

PlayerEvent.player


RecipeCraftedEvent ​

Defined in: events.ts:59

A recipe the player or a crafter finished, with the stacks it consumed.

Extends ​

Properties ​

ingredients ​

readonly ingredients: readonly ItemStack[]

Defined in: events.ts:60

player ​

readonly player: EntityView

Defined in: events.ts:22

Inherited from ​

RecipeEvent.player

recipe ​

readonly recipe: string

Defined in: events.ts:55

Namespaced recipe identifier.

Inherited from ​

RecipeEvent.recipe


RecipeEvent ​

Defined in: events.ts:53

A recipe the player unlocked.

Extends ​

Extended by ​

Properties ​

player ​

readonly player: EntityView

Defined in: events.ts:22

Inherited from ​

PlayerEvent.player

recipe ​

readonly recipe: string

Defined in: events.ts:55

Namespaced recipe identifier.


RewardHooks ​

Defined in: engine.ts:26

Where the four reward kinds land. Every hook is optional, and a reward with no hook reports a diagnostic rather than failing the completion, so a server can ship advancements before it has a loot runner or a function runtime. The function hook is the seam @jsprismarine/mcfunction fills.

Methods ​

grantExperience()? ​

optional grantExperience(player, amount): void

Defined in: engine.ts:28

Adds experience points, not levels, which is what rewards.experience counts.

Parameters ​
player ​

EntityView

amount ​

number

Returns ​

void

runFunction()? ​

optional runFunction(player, id): void

Defined in: engine.ts:32

Parameters ​
player ​

EntityView

id ​

string

Returns ​

void

runLootTable()? ​

optional runLootTable(player, lootTable): void

Defined in: engine.ts:30

Rolls a loot table and gives the player what it produced.

Parameters ​
player ​

EntityView

lootTable ​

string

Returns ​

void

unlockRecipe()? ​

optional unlockRecipe(player, recipe): void

Defined in: engine.ts:31

Parameters ​
player ​

EntityView

recipe ​

string

Returns ​

void


SpearMobsEvent ​

Defined in: events.ts:203

Mobs a thrown trident pinned at once.

Extends ​

Properties ​

count ​

readonly count: number

Defined in: events.ts:204

player ​

readonly player: EntityView

Defined in: events.ts:22

Inherited from ​

PlayerEvent.player


TargetHitEvent ​

Defined in: events.ts:216

A target block a projectile hit.

Extends ​

Properties ​

player ​

readonly player: EntityView

Defined in: events.ts:22

Inherited from ​

PlayerEvent.player

projectile ​

readonly projectile: EntityView

Defined in: events.ts:219

signalStrength ​

readonly signalStrength: number

Defined in: events.ts:218

Redstone signal the hit produced, 0 to 15.


TravelEvent ​

Defined in: events.ts:174

Travel measured from where it started, for nether_travel and the two fall triggers.

Extends ​

Extended by ​

Properties ​

player ​

readonly player: EntityView

Defined in: events.ts:22

Inherited from ​

PlayerEvent.player

startPosition ​

readonly startPosition: Vec3

Defined in: events.ts:175


TriggerEvents ​

Defined in: triggers.ts:141

Which event shape each trigger listens for. A host raises one of these and the engine routes it to the criteria registered under that trigger.

Properties ​

allay_drop_item_on_block ​

allay_drop_item_on_block: ItemUsedOnBlockEvent

Defined in: triggers.ts:195

any_block_use ​

any_block_use: BlockInteractionEvent

Defined in: triggers.ts:183

avoid_vibration ​

avoid_vibration: PlayerEvent

Defined in: triggers.ts:196

bee_nest_destroyed ​

bee_nest_destroyed: BeeNestDestroyedEvent

Defined in: triggers.ts:179

bred_animals ​

bred_animals: BredAnimalsEvent

Defined in: triggers.ts:156

brewed_potion ​

brewed_potion: BrewedPotionEvent

Defined in: triggers.ts:152

changed_dimension ​

changed_dimension: ChangedDimensionEvent

Defined in: triggers.ts:163

channeled_lightning ​

channeled_lightning: VictimsEvent

Defined in: triggers.ts:172

construct_beacon ​

construct_beacon: BeaconEvent

Defined in: triggers.ts:153

consume_item ​

consume_item: ItemEvent

Defined in: triggers.ts:167

crafter_recipe_crafted ​

crafter_recipe_crafted: RecipeCraftedEvent

Defined in: triggers.ts:198

cured_zombie_villager ​

cured_zombie_villager: CuredZombieVillagerEvent

Defined in: triggers.ts:159

default_block_use ​

default_block_use: BlockInteractionEvent

Defined in: triggers.ts:182

effects_changed ​

effects_changed: EffectsChangedEvent

Defined in: triggers.ts:168

enchanted_item ​

enchanted_item: EnchantedItemEvent

Defined in: triggers.ts:150

enter_block ​

enter_block: BlockEvent

Defined in: triggers.ts:145

entity_hurt_player ​

entity_hurt_player: DamageEvent

Defined in: triggers.ts:149

entity_killed_player ​

entity_killed_player: KillEvent

Defined in: triggers.ts:144

fall_after_explosion ​

fall_after_explosion: FallAfterExplosionEvent

Defined in: triggers.ts:199

fall_from_height ​

fall_from_height: TravelEvent

Defined in: triggers.ts:192

filled_bucket ​

filled_bucket: ItemEvent

Defined in: triggers.ts:151

fishing_rod_hooked ​

fishing_rod_hooked: FishingRodHookedEvent

Defined in: triggers.ts:171

hero_of_the_village ​

hero_of_the_village: PlayerEvent

Defined in: triggers.ts:176

impossible ​

impossible: PlayerEvent

Defined in: triggers.ts:142

inventory_changed ​

inventory_changed: InventoryEvent

Defined in: triggers.ts:146

item_durability_changed ​

item_durability_changed: ItemDurabilityEvent

Defined in: triggers.ts:161

item_used_on_block ​

item_used_on_block: ItemUsedOnBlockEvent

Defined in: triggers.ts:181

kill_mob_near_sculk_catalyst ​

kill_mob_near_sculk_catalyst: KillEvent

Defined in: triggers.ts:194

killed_by_arrow ​

killed_by_arrow: KilledByArrowEvent

Defined in: triggers.ts:175

levitation ​

levitation: LevitationEvent

Defined in: triggers.ts:162

lightning_strike ​

lightning_strike: LightningStrikeEvent

Defined in: triggers.ts:190

location ​

location: PlayerEvent

Defined in: triggers.ts:157

nether_travel ​

nether_travel: TravelEvent

Defined in: triggers.ts:170

placed_block ​

placed_block: ItemUsedOnBlockEvent

Defined in: triggers.ts:166

player_generates_container_loot ​

player_generates_container_loot: ContainerLootEvent

Defined in: triggers.ts:184

player_hurt_entity ​

player_hurt_entity: PlayerHurtEntityEvent

Defined in: triggers.ts:148

player_interacted_with_entity ​

player_interacted_with_entity: PlayerInteractEvent

Defined in: triggers.ts:187

player_killed_entity ​

player_killed_entity: KillEvent

Defined in: triggers.ts:143

player_sheared_equipment ​

player_sheared_equipment: PlayerInteractEvent

Defined in: triggers.ts:188

recipe_crafted ​

recipe_crafted: RecipeCraftedEvent

Defined in: triggers.ts:197

recipe_unlocked ​

recipe_unlocked: RecipeEvent

Defined in: triggers.ts:147

ride_entity_in_lava ​

ride_entity_in_lava: TravelEvent

Defined in: triggers.ts:193

shot_crossbow ​

shot_crossbow: ItemEvent

Defined in: triggers.ts:173

slept_in_bed ​

slept_in_bed: PlayerEvent

Defined in: triggers.ts:158

slide_down_block ​

slide_down_block: BlockEvent

Defined in: triggers.ts:178

spear_mobs ​

spear_mobs: SpearMobsEvent

Defined in: triggers.ts:174

started_riding ​

started_riding: PlayerEvent

Defined in: triggers.ts:189

summoned_entity ​

summoned_entity: EntityEvent

Defined in: triggers.ts:155

tame_animal ​

tame_animal: EntityEvent

Defined in: triggers.ts:165

target_hit ​

target_hit: TargetHitEvent

Defined in: triggers.ts:180

thrown_item_picked_up_by_entity ​

thrown_item_picked_up_by_entity: PickedUpItemEvent

Defined in: triggers.ts:185

thrown_item_picked_up_by_player ​

thrown_item_picked_up_by_player: PickedUpItemEvent

Defined in: triggers.ts:186

tick ​

tick: PlayerEvent

Defined in: triggers.ts:164

used_ender_eye ​

used_ender_eye: EnderEyeEvent

Defined in: triggers.ts:154

used_totem ​

used_totem: ItemEvent

Defined in: triggers.ts:169

using_item ​

using_item: ItemEvent

Defined in: triggers.ts:191

villager_trade ​

villager_trade: VillagerTradeEvent

Defined in: triggers.ts:160

voluntary_exile ​

voluntary_exile: PlayerEvent

Defined in: triggers.ts:177


VictimsEvent ​

Defined in: events.ts:193

Several entities hit at once, by a channeled lightning bolt or one arrow.

Extends ​

Extended by ​

Properties ​

player ​

readonly player: EntityView

Defined in: events.ts:22

Inherited from ​

PlayerEvent.player

victims ​

readonly victims: readonly EntityView[]

Defined in: events.ts:194


VillagerTradeEvent ​

Defined in: events.ts:122

A villager trade the player completed.

Extends ​

Properties ​

item ​

readonly item: ItemStack

Defined in: events.ts:125

The stack the player received.

player ​

readonly player: EntityView

Defined in: events.ts:22

Inherited from ​

PlayerEvent.player

villager ​

readonly villager: EntityView

Defined in: events.ts:123

Type Aliases ​

AdvancementFrame ​

AdvancementFrame = typeof ADVANCEMENT_FRAMES[number]

Defined in: model.ts:22

One of ADVANCEMENT_FRAMES.


AnyTriggerEvent ​

AnyTriggerEvent = TriggerEvents[TriggerName]

Defined in: triggers.ts:203

The union of every event shape, which is what the dispatch index erases to.


CriterionTest ​

CriterionTest<K> = EventTest<TriggerEvents[K]>

Defined in: triggers.ts:212

A compiled criterion test for one trigger.

Type Parameters ​

K ​

K extends TriggerName


EventParser ​

EventParser<E> = (conditions, context) => EventTest<E>

Defined in: triggers.ts:209

Compiles a conditions object into a test over one event shape.

Type Parameters ​

E ​

E

Parameters ​

conditions ​

unknown

context ​

ParseContext

Returns ​

EventTest<E>


EventTest ​

EventTest<E> = (event, services) => boolean

Defined in: triggers.ts:206

Answers whether one event satisfies a criterion.

Type Parameters ​

E ​

E

Parameters ​

event ​

E

services ​

EvaluationServices

Returns ​

boolean


KeyedTrigger ​

KeyedTrigger = keyof typeof KEYED_TRIGGERS

Defined in: triggers.ts:835

One of the keys of KEYED_TRIGGERS.


PlayerProgressJson ​

PlayerProgressJson = Readonly<Record<string, AdvancementProgressJson>>

Defined in: progress.ts:29

Every advancement a player has touched, keyed by namespaced advancement id.


TriggerName ​

TriggerName = typeof TRIGGER_TYPES[number]

Defined in: triggers.ts:135

One of TRIGGER_TYPES, without the minecraft: namespace.


TriggerParser ​

TriggerParser<K> = EventParser<TriggerEvents[K]>

Defined in: triggers.ts:215

Compiles one trigger's conditions object into a test over its event.

Type Parameters ​

K ​

K extends TriggerName

Variables ​

ADVANCEMENT_FRAMES ​

const ADVANCEMENT_FRAMES: readonly ["task", "challenge", "goal"]

Defined in: model.ts:19

The three icon frames AdvancementType registers, which decide the toast wording and title color.


KEYED_TRIGGERS ​

const KEYED_TRIGGERS: object

Defined in: triggers.ts:827

The triggers whose event names one registry element, and the conditions field that holds the ids it must be one of. The dispatch index keys criteria of these triggers by those ids, which is what keeps the recipe-unlock path off a scan through the 1739 vanilla criteria that use it.

Type Declaration ​

crafter_recipe_crafted ​

readonly crafter_recipe_crafted: object

crafter_recipe_crafted.field ​

readonly field: "recipes" = 'recipes'

crafter_recipe_crafted.registry ​

readonly registry: "recipe" = 'recipe'

player_generates_container_loot ​

readonly player_generates_container_loot: object

player_generates_container_loot.field ​

readonly field: "loot_tables" = 'loot_tables'

player_generates_container_loot.registry ​

readonly registry: "loot_table" = 'loot_table'

recipe_crafted ​

readonly recipe_crafted: object

recipe_crafted.field ​

readonly field: "recipes" = 'recipes'

recipe_crafted.registry ​

readonly registry: "recipe" = 'recipe'

recipe_unlocked ​

readonly recipe_unlocked: object

recipe_unlocked.field ​

readonly field: "recipes" = 'recipes'

recipe_unlocked.registry ​

readonly registry: "recipe" = 'recipe'


TRIGGER_TYPES ​

const TRIGGER_TYPES: readonly ["impossible", "player_killed_entity", "entity_killed_player", "enter_block", "inventory_changed", "recipe_unlocked", "player_hurt_entity", "entity_hurt_player", "enchanted_item", "filled_bucket", "brewed_potion", "construct_beacon", "used_ender_eye", "summoned_entity", "bred_animals", "location", "slept_in_bed", "cured_zombie_villager", "villager_trade", "item_durability_changed", "levitation", "changed_dimension", "tick", "tame_animal", "placed_block", "consume_item", "effects_changed", "used_totem", "nether_travel", "fishing_rod_hooked", "channeled_lightning", "shot_crossbow", "spear_mobs", "killed_by_arrow", "hero_of_the_village", "voluntary_exile", "slide_down_block", "bee_nest_destroyed", "target_hit", "item_used_on_block", "default_block_use", "any_block_use", "player_generates_container_loot", "thrown_item_picked_up_by_entity", "thrown_item_picked_up_by_player", "player_interacted_with_entity", "player_sheared_equipment", "started_riding", "lightning_strike", "using_item", "fall_from_height", "ride_entity_in_lava", "kill_mob_near_sculk_catalyst", "allay_drop_item_on_block", "avoid_vibration", "recipe_crafted", "crafter_recipe_crafted", "fall_after_explosion"]

Defined in: triggers.ts:73

The 58 members of the minecraft:trigger_type registry in Java 26.3, read out of reports/registries.json in protocol id order. Vanilla's own 1866 advancement files use 54 of them; used_ender_eye, voluntary_exile, default_block_use and any_block_use have no vanilla criterion.

Functions ​

blockUseContext() ​

blockUseContext(event, services): PredicateContext

Defined in: events.ts:314

Builds the block_use context default_block_use and any_block_use evaluate their location field in.

Parameters ​

event ​

BlockInteractionEvent

services ​

EvaluationServices

Returns ​

PredicateContext


buildAdvancementTree() ​

buildAdvancementTree(advancements, collector?): object

Defined in: tree.ts:56

Links parsed advancements into the tree the client draws as tabs.

A parent that names nothing in the set reports and leaves the node a root, so an incomplete datapack still produces a usable tree. A parent chain that closes on itself reports at the first node whose walk revisits an identifier and detaches that node, which breaks the cycle, keeps the rest of the chain linked, and stops any later walk from looping.

Parameters ​

advancements ​

Iterable<ParsedAdvancement>

The parsed files, which decide root ordering.

collector? ​

DiagnosticCollector = ...

Returns ​

object

The tree together with every fault found while linking it.

diagnostics ​

readonly diagnostics: readonly Diagnostic[]

tree ​

readonly tree: AdvancementTree


criterionKeys() ​

criterionKeys(trigger, conditions, context): readonly string[] | undefined

Defined in: triggers.ts:845

The registry ids a criterion can match, for a trigger KEYED_TRIGGERS covers. Undefined means the criterion belongs in its trigger's linear bucket, either because the trigger is not keyed or because the field is absent.

Parameters ​

trigger ​

"villager_trade" | "enchanted_item" | "impossible" | "player_killed_entity" | "entity_killed_player" | "enter_block" | "inventory_changed" | "recipe_unlocked" | "player_hurt_entity" | "entity_hurt_player" | "filled_bucket" | "brewed_potion" | "construct_beacon" | "used_ender_eye" | "summoned_entity" | "bred_animals" | "location" | "slept_in_bed" | "cured_zombie_villager" | "item_durability_changed" | "levitation" | "changed_dimension" | "tick" | "tame_animal" | "placed_block" | "consume_item" | "effects_changed" | "used_totem" | "nether_travel" | "fishing_rod_hooked" | "channeled_lightning" | "shot_crossbow" | "spear_mobs" | "killed_by_arrow" | "hero_of_the_village" | "voluntary_exile" | "slide_down_block" | "bee_nest_destroyed" | "target_hit" | "item_used_on_block" | "default_block_use" | "any_block_use" | "player_generates_container_loot" | "thrown_item_picked_up_by_entity" | "thrown_item_picked_up_by_player" | "player_interacted_with_entity" | "player_sheared_equipment" | "started_riding" | "lightning_strike" | "using_item" | "fall_from_height" | "ride_entity_in_lava" | "kill_mob_near_sculk_catalyst" | "allay_drop_item_on_block" | "avoid_vibration" | "recipe_crafted" | "crafter_recipe_crafted" | "fall_after_explosion"

conditions ​

unknown

context ​

ParseContext

Returns ​

readonly string[] | undefined


entityContext() ​

entityContext(entity, services): PredicateContext

Defined in: events.ts:276

Builds the advancement_entity context Java's EntityPredicate.wrap uses for the player field and every other entity field on a trigger.

Parameters ​

entity ​

EntityView | undefined

services ​

EvaluationServices

Returns ​

PredicateContext


eventKey() ​

eventKey(trigger, event): string | undefined

Defined in: triggers.ts:857

The registry id one event names, for a trigger KEYED_TRIGGERS covers.

Parameters ​

trigger ​

"villager_trade" | "enchanted_item" | "impossible" | "player_killed_entity" | "entity_killed_player" | "enter_block" | "inventory_changed" | "recipe_unlocked" | "player_hurt_entity" | "entity_hurt_player" | "filled_bucket" | "brewed_potion" | "construct_beacon" | "used_ender_eye" | "summoned_entity" | "bred_animals" | "location" | "slept_in_bed" | "cured_zombie_villager" | "item_durability_changed" | "levitation" | "changed_dimension" | "tick" | "tame_animal" | "placed_block" | "consume_item" | "effects_changed" | "used_totem" | "nether_travel" | "fishing_rod_hooked" | "channeled_lightning" | "shot_crossbow" | "spear_mobs" | "killed_by_arrow" | "hero_of_the_village" | "voluntary_exile" | "slide_down_block" | "bee_nest_destroyed" | "target_hit" | "item_used_on_block" | "default_block_use" | "any_block_use" | "player_generates_container_loot" | "thrown_item_picked_up_by_entity" | "thrown_item_picked_up_by_player" | "player_interacted_with_entity" | "player_sheared_equipment" | "started_riding" | "lightning_strike" | "using_item" | "fall_from_height" | "ride_entity_in_lava" | "kill_mob_near_sculk_catalyst" | "allay_drop_item_on_block" | "avoid_vibration" | "recipe_crafted" | "crafter_recipe_crafted" | "fall_after_explosion"

event ​

AnyTriggerEvent

Returns ​

string | undefined


isTriggerName() ​

isTriggerName(value): value is "villager_trade" | "enchanted_item" | "impossible" | "player_killed_entity" | "entity_killed_player" | "enter_block" | "inventory_changed" | "recipe_unlocked" | "player_hurt_entity" | "entity_hurt_player" | "filled_bucket" | "brewed_potion" | "construct_beacon" | "used_ender_eye" | "summoned_entity" | "bred_animals" | "location" | "slept_in_bed" | "cured_zombie_villager" | "item_durability_changed" | "levitation" | "changed_dimension" | "tick" | "tame_animal" | "placed_block" | "consume_item" | "effects_changed" | "used_totem" | "nether_travel" | "fishing_rod_hooked" | "channeled_lightning" | "shot_crossbow" | "spear_mobs" | "killed_by_arrow" | "hero_of_the_village" | "voluntary_exile" | "slide_down_block" | "bee_nest_destroyed" | "target_hit" | "item_used_on_block" | "default_block_use" | "any_block_use" | "player_generates_container_loot" | "thrown_item_picked_up_by_entity" | "thrown_item_picked_up_by_player" | "player_interacted_with_entity" | "player_sheared_equipment" | "started_riding" | "lightning_strike" | "using_item" | "fall_from_height" | "ride_entity_in_lava" | "kill_mob_near_sculk_catalyst" | "allay_drop_item_on_block" | "avoid_vibration" | "recipe_crafted" | "crafter_recipe_crafted" | "fall_after_explosion"

Defined in: triggers.ts:869

Whether a string names one of TRIGGER_TYPES, with or without the minecraft: namespace.

Parameters ​

value ​

string

Returns ​

value is "villager_trade" | "enchanted_item" | "impossible" | "player_killed_entity" | "entity_killed_player" | "enter_block" | "inventory_changed" | "recipe_unlocked" | "player_hurt_entity" | "entity_hurt_player" | "filled_bucket" | "brewed_potion" | "construct_beacon" | "used_ender_eye" | "summoned_entity" | "bred_animals" | "location" | "slept_in_bed" | "cured_zombie_villager" | "item_durability_changed" | "levitation" | "changed_dimension" | "tick" | "tame_animal" | "placed_block" | "consume_item" | "effects_changed" | "used_totem" | "nether_travel" | "fishing_rod_hooked" | "channeled_lightning" | "shot_crossbow" | "spear_mobs" | "killed_by_arrow" | "hero_of_the_village" | "voluntary_exile" | "slide_down_block" | "bee_nest_destroyed" | "target_hit" | "item_used_on_block" | "default_block_use" | "any_block_use" | "player_generates_container_loot" | "thrown_item_picked_up_by_entity" | "thrown_item_picked_up_by_player" | "player_interacted_with_entity" | "player_sheared_equipment" | "started_riding" | "lightning_strike" | "using_item" | "fall_from_height" | "ride_entity_in_lava" | "kill_mob_near_sculk_catalyst" | "allay_drop_item_on_block" | "avoid_vibration" | "recipe_crafted" | "crafter_recipe_crafted" | "fall_after_explosion"


locationContext() ​

locationContext(event, services): PredicateContext

Defined in: events.ts:295

Builds the advancement_location context the placed_block family evaluates its location field in.

Parameters ​

event ​

ItemUsedOnBlockEvent

services ​

EvaluationServices

Returns ​

PredicateContext


parseAdvancement() ​

parseAdvancement(id, json, options?): ParseResult<ParsedAdvancement | undefined>

Defined in: model.ts:252

Parses one advancement file. Nothing throws: a fault lands in the diagnostics and the value is undefined only when the file has no usable criterion at all.

Parameters ​

id ​

string

Namespaced identifier the file is registered under.

json ​

unknown

options? ​

ParseOptions

Pass resolver so #tag references in rewards.loot, recipes fields and nested loot conditions resolve, and diagnostics to gather a whole datapack into one report.

Returns ​

ParseResult<ParsedAdvancement | undefined>


parseTrigger() ​

parseTrigger<K>(trigger, conditions, context): CriterionTest<K>

Defined in: triggers.ts:877

Compiles one criterion's conditions into a test over the event its trigger declares.

Type Parameters ​

K ​

K extends "villager_trade" | "enchanted_item" | "impossible" | "player_killed_entity" | "entity_killed_player" | "enter_block" | "inventory_changed" | "recipe_unlocked" | "player_hurt_entity" | "entity_hurt_player" | "filled_bucket" | "brewed_potion" | "construct_beacon" | "used_ender_eye" | "summoned_entity" | "bred_animals" | "location" | "slept_in_bed" | "cured_zombie_villager" | "item_durability_changed" | "levitation" | "changed_dimension" | "tick" | "tame_animal" | "placed_block" | "consume_item" | "effects_changed" | "used_totem" | "nether_travel" | "fishing_rod_hooked" | "channeled_lightning" | "shot_crossbow" | "spear_mobs" | "killed_by_arrow" | "hero_of_the_village" | "voluntary_exile" | "slide_down_block" | "bee_nest_destroyed" | "target_hit" | "item_used_on_block" | "default_block_use" | "any_block_use" | "player_generates_container_loot" | "thrown_item_picked_up_by_entity" | "thrown_item_picked_up_by_player" | "player_interacted_with_entity" | "player_sheared_equipment" | "started_riding" | "lightning_strike" | "using_item" | "fall_from_height" | "ride_entity_in_lava" | "kill_mob_near_sculk_catalyst" | "allay_drop_item_on_block" | "avoid_vibration" | "recipe_crafted" | "crafter_recipe_crafted" | "fall_after_explosion"

Parameters ​

trigger ​

K

A registered trigger name without its namespace.

conditions ​

unknown

context ​

ParseContext

Returns ​

CriterionTest<K>


requirementsCount() ​

requirementsCount(requirements, isDone): number

Defined in: progress.ts:16

How many of the requirements groups are satisfied, which is what a progress bar shows.

Parameters ​

requirements ​

readonly (readonly string[])[]

isDone ​

(criterion) => boolean

Returns ​

number


requirementsMet() ​

requirementsMet(requirements, isDone): boolean

Defined in: progress.ts:10

Whether the conjunctive normal form in requirements is satisfied: every group needs at least one completed criterion. The single-criterion default is one group of one name, so it completes with that criterion.

Parameters ​

requirements ​

readonly (readonly string[])[]

isDone ​

(criterion) => boolean

Answers whether one criterion name has been completed.

Returns ​

boolean