The bug
As of 20w18a, all advancement triggers (with the intended exception of impossible
) have access to a player
predicate to check the player that activated the trigger. An example:
{
"criteria": {
"test": {
"trigger": "minecraft:location",
"conditions": {
"player": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"flags": {
"is_sprinting": true
}
}
}
]
}
}
}
}
However, the predicate does not work in the minecraft:tick
trigger.
{
"criteria": {
"test": {
"trigger": "minecraft:tick",
"conditions": {
"player": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"flags": {
"is_sprinting": true
}
}
}
]
}
}
}
}
Code analysis
Using Mojang's mappings for 20w18a:
There are two trigger
methods in net.minecraft.advancements.critereon.SimpleCriterionTrigger
: one that takes in a predicate (which, to be clear, is a consolidation of the trigger's conditions, not player
) and one that does not. The first method checks the player
predicate but the second does not.
minecraft:tick
uses the second method, preventing the use of player
.
Comments 9
The enter_block
advancement trigger can be used as a workaround if you want to check only once:
{
"criteria": {
"enter_block": {
"trigger": "enter_block",
"conditions": {
"player": [
{
"condition": "entity_properties",
"entity": "this",
"predicate": {
"flags": {
"is_sprinting": true
}
}
}
]
}
}
}
}
Regardless, the bug still needs to be fixed for the trigger to be intuitive to other players.
Confirmed, it's happened to me and a few others as well