mojira.dev
MC-268534

Inverted killed_by_player still triggers if killed by player

An advancement to detect when a player hurts an entity but does not kill it. The inverted killed_by_player triggers even if the player kills the entity.

{
  "criteria": {
    "projectile": {
      "trigger": "minecraft:player_hurt_entity",
      "conditions": {
        "entity": [
          {
            "condition": "minecraft:inverted",
            "term": {
              "condition": "minecraft:killed_by_player"
            }
          }
        ]
      }
    }
  }
}

Attachments

Comments 3

Please attach a minimal setup datapack to reproduce this.

I have attached a datapack to demonstrate this. To test this bug,

  1. Kill an entity in one hit (e.g. fish with axe)

  2. Try to revoke the advancement:

    /advancement revoke @s only test:hurt_by_player

You will see the message "Revoked the advancement ..." which is incorrect because the entity was killed a player. Instead the message "Couldn't revoke advancement ... as they don't have it", indicating that the advancement was not triggered.

However, one might argue that this is not a bug. "killed_by_player" is meant as a condition for loot tables and not for advancements. In fact, not even the "player_killed_entity" criterion sets the "killed_by_player" condition.

That being said, I included a version of the advancement that checks for health being 0 instead of using "killed_by_player". This version can be found under test:hurt_by_player2 and does not trigger on kill like expected.

The "killed_by_player" condition has an optional field, "inverse", which defaults to false, so what I'm assuming happens here is that the game only looks at that field to determine if it should invert the condition, and not if it is inside an "inverted" condition.

Edit: Nope. Forget what I wrote above. This issue is invalid. The condition "killed_by_player" does not have all required loot context parameters in advancements, since the "advancement" loot context type only provides the "this" entity and the origin, and "killed_by_player" requires the "killer_player" entity to be provided. Using the attached datapack produces an error in the output log because the advancement is trying to use a condition that does not have all required loot context parameters.

Gatinh0

(Unassigned)

Community Consensus

Platform

Normal

Advancements, Data Packs

1.20.4

Retrieved