The bug
The advancement trigger entity_hurt_player is triggered when the player receives non-entity damage (like fire) as well but the trigger entity_killed_player is only triggered if the player is killed by an entity.
Note: If both triggers should trigger for non-entity damage as well it might be good to rename them to something like player_being_hurt and player_being_killed.
How to reproduce
Download the attached datapack
and place it in the
datapacksdirectory of your world folderLoad the world (or if it's already opened run
/reload)Take fire damage
→ You get the advancement "Taking damage"Die because of fire damage
→ You do not get the advancement "Being killed"
Linked issues
is duplicated by 1
Attachments
Comments 4
Here is a simple workaround that can be used in 20w18a and above.
Create a deathCount scoreboard objective with the following command:
/scoreboard objectives add deathCount deathCountThen, create an entity_hurt_player advancement with an entity_scores predicate condition that checks if the deathCount score increased:
{
"criteria": {
"entity_killed_player": {
"trigger": "entity_hurt_player",
"conditions": {
"player": [
{
"condition": "entity_scores",
"entity": "this",
"scores": {
"deathCount": 1
}
}
]
}
}
}
}It works well if the player has to die only once for the advancement to be granted. If the advancement has to be revoked with a reward function, a simple rewards parameter with a function reward can be added after criteria.
The reward function should have the following minimum code:
advancement revoke @s only <advancement>
scoreboard players reset @s deathCountConfirmed in 1.21.5.
I’d also like to point out that if this were “fixed” (as in the trigger was made to only respond to entities), universal damage tracking would no longer be possible in datapacks, period. As it stands now, we can force this trigger to only respond to entities by including a check for the direct entity in the provided damage condition, so this bug doesn’t render any functionality unattainable.
The “fix” for this bug should 100% be to just change the name of the trigger to minecraft:player_damaged or something like that.
Confirmed in 20w21a.