mojira.dev
MC-116922

entity_hurt_player advancement trigger is triggered for non-entity damage but entity_killed_player is not

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

  1. Download the attached datapack

[media]
  1. and place it in the datapacks directory of your world folder

  2. Load the world (or if it's already opened run /reload)

  3. Take fire damage
    → You get the advancement "Taking damage"

  4. Die because of fire damage
    → You do not get the advancement "Being killed"

Linked issues

Attachments

Comments 4

Confirmed in 20w21a.

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 deathCount

Then, 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 deathCount

Confirmed in 20w27a.

Confirmed 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.

marcono1234

(Unassigned)

Confirmed

Platform

Low

Advancements

advancement, damage, entity, trigger

Minecraft 17w17b, 1.15.2, 20w06a, 20w07a, 20w21a, ..., 20w27a, 1.17.1, 23w03a, 1.20.4, 24w09a

Retrieved