Events
Events use advancements to detect player/entity actions and dispatch them to function tags. Multiple handlers can be registered for the same event - they all fire together.
This makes events a convenient bridge between vanilla triggers and OOP-style gameplay code: you register interest once, then let the generated dispatchers call your handlers when Minecraft reports the action.
Player events
Available player events (alphabetical):
| Function | Trigger |
|---|---|
onBlockUse |
Right-click any block |
onChangeDimension |
Change dimension |
onConsumeItem |
Consume any item (food, potion, etc.) |
onConsumeItem(item) |
Consume a specific item |
onEffectsChanged |
Effects on the player change |
onEnchantItem |
Enchant an item |
onEntityHurtPlayer |
A player is hurt by an entity |
onFallFromHeight |
Fall from a height |
onHurtEntity |
Deal damage to an entity |
onInventoryChange |
Inventory contents change |
onItemUsedOnBlock |
Use an item on a block |
onKill |
Kill an entity |
onPlaceBlock |
Place a block |
onRecipeCrafted |
Craft a recipe |
onRightClick(item) |
Right-click while holding an item |
onSleptInBed |
Sleep in a bed |
onStartRiding |
Start riding an entity |
onTameAnimal |
Tame an animal |
onTargetHit |
Hit a target block |
Typical workflow
- Declare the entity or player handle that should receive the event helpers.
- Register one or more event handlers inside a function.
- Keep the handler bodies focused on gameplay reactions such as score updates, messaging, or spawning.
This pattern works well for mini-games where multiple systems need to react to the same player action.
Entity events
The death event uses a loot-table trigger: on death the entity drops a hidden item detected by a tick dispatcher that runs all death handlers then removes the item.
See also
- Cooldowns – Gate event-driven abilities or interactions so players cannot spam them.
- Entities & Players – Build the selectors and entity handles that receive these event helpers.
- Items – React to item usage or rewards with reusable item stacks.
