The purpose of events is to have triggers without needing an advancement for it. This should go hand in hand with the current data driven files. We have been using advancements for a totally different reason than what they were intended for. And that's what we wanted to avoid from 1.13 onwards. A few advantages is they work for all entities, not only for players. They keep triggering, so you don't need to revoke the advancement.
Events are json files put in namespace/data/events
Its structure is very similar to the current advancement structure of a criteria.
This event would run namespace:foo
for every zombie that hurts a player in a plains biome
{
"event": {
"trigger": "minecraft:hurt_entity",
"conditions": {
"entity": {
"type": "minecraft:player",
"location": {
"biome": "minecraft:plains"
}
},
"entity": {
"type": "minecraft:zombie"
}
},
"actions": {
"function": "namespace:foo"
}
}
The "event"
component has an almost identical structure as a "criteria"
component in an advancement. The only difference is the "entity"
component which specifies the entity that is triggering the event. For advancements this would be the player.
The "actions"
component tells the event what function it should run. The function is ran executed as and at the entity that triggered the event. In this case the zombie
- Advancements can reference an event in a criteria component by leaving out the
"trigger"
an including a"event": "namespace:foo"
(wherenamespace:foo
is the event) - Advancements can still have the triggers inside them. The
"entity"
component though cannot be changed because it defaults to players. - Some triggers like
player_hurt_entity
,placed_block
, etc. only apply to players. The event would simply only run for players - Some more triggers need to be added, like
hurt_entity
andkilled_entity