mojira.dev
MC-267563

entity_hurt_player advancement triggers with wrong damage type context

If a player is hurt by something that isn't an entity, the next time the player triggers the entity_hurt_player advancement, it has the wrong damage type context. This causes a simple hit by a zombie after being on fire to get true as result for the damage condition 
minecraft:is_fire.
 

Steps to Reproduce:

  1. Create an advancement with the following content

    {
      "criteria": {
        "target": {
          "trigger": "minecraft:entity_hurt_player",
          "conditions": {
            "damage": {
              "source_entity": {
                "type": "minecraft:zombie"
              }
            }
          }
        },
        "fire": {
          "trigger": "minecraft:entity_hurt_player",
          "conditions": {
            "damage": {
              "type": {
                "tags": [
                  {
                    "id": "minecraft:is_fire",
                    "expected": true
                  }
                ]
              }
            }
          }
        },
        "!fire": {
          "trigger": "minecraft:entity_hurt_player",
          "conditions": {
            "damage": {
              "type": {
                "tags": [
                  {
                    "id": "minecraft:is_fire",
                    "expected": false
                  }
                ]
              }
            }
          }
        }
      },
      "requirements": [
        [
          "target"
        ],
        [
          "fire",
          "!fire"
        ]
      ],
      "rewards": {
        "function": "namespace:on_hurt"
      }
    }
  2. Create the reward function referenced by the advancement with the following content:

    execute if entity @s[advancements={namespace:on_hurt={fire=true}}] run say Damage Type Fire
    advancement revoke @s only namespace:on_hurt
  3. Load the datapack in a minecraft world.

  4. Cause your player damage in one of these ways:

    1. Set yourself on fire and wait for the fire to go away

    2. Simply use the command: /damage @s 1 minecraft:in_fire

  5. Summon a zombie

  6. Let the zombie hit you

  7. You will see the message "Damage Type Fire" in the chat

  8. Let the zombie hit you again

  9. Now the message won't show (until being hurt by fire again)

Observed Results:

The hit by the zombie sets the fire criteria to true

Expected Results:

The hit by the zombie sets the fire criteria to false

Notes:

This problem is not only present for being hurt by fire. I see the same problem when checking for the damage type minecraft:magic. In this case if for example the poison effect is active on a player, the hit of a zombie is also processed as a damage type minecraft:magic.

The problem seems to be with any type of hit that is not caused by a source entity.

I have also tested with a player_hurt_entity advancement, I don't see the same issue here. 

Comments 4

Could you please attach a minimal setup data pack to reproduce the issue?

I thought it's invalid, once the criterion is completed, it wouldn't be reverted until you manually revoke it or the advancement it belonged.

I cannot reproduce this with the provided data pack contents.

Please check if this is still an issue for you in 1.21. This ticket will automatically reopen when you reply.

knickknacker

(Unassigned)

Unconfirmed

Advancements, Data Packs

1.20.4

Retrieved