mojira.dev
MC-307438

Predicate condition "targeted_entity" does not work for interaction entities

An interaction that is targeting a player will not be detected by a predicate checking “targeted_entity” under the “entity_properties” condition, which is inconsistent with other entities/mobs that can target players, and with “execute on target …” commands.

Steps to reproduce:

  • Create a new world with mob spawning disabled to ensure no other entities interfere with the test.

  • Add a data pack to the world containing the following predicate:

    • data/test/predicate/targeting_player.json
      {
          "condition": "minecraft:entity_properties",
          "entity": "this",
          "predicate": {
              "targeted_entity": {
                  "type": "minecraft:player"
              }
          }
      }
  • Spawn a zombie, either through /summon or with a spawn egg, to use as a control for the test. (Block it in so it can’t hurt the player, burn to death, or wander off while testing)

  • Summon a minecraft:interaction entity.

  • Change game mode to survival or adventure, right click on the interaction, and attack the zombie to make both entities target the player.

  • Run the following command to check that both entities are targeting the player:

    • /execute as @e on target run say hi
  • Run the following command to check whether the predicate works:

    • /execute as @e[predicate=test:targeting_player] run say hi

Expected result:

  • The first command results in the following, showing that both entities are targeting the player.

    • [player_name] hi
      [player_name] hi
  • The second command should result in the following, showing that both entities are targeting the player

    • [Interaction] hi
      [Zombie] hi

Actual result:

  • The first command behaves as expected, resulting in the chat messages shown above

  • The second command results in only the following, showing that the predicate only succeeded for the control zombie, but not the interaction.

    • [Zombie] hi

More info:

I first discovered this bug in 1.21.11, but have confirmed this also exists in 26.1.2, and 26.2-snapshot-2 as well. The screenshots below show the bug occurring in 26.1.2, as well as the predicate JSON used.

Attachments

Comments 1

Thank you for helping us improve Minecraft! We saved your files:

[media][media]

Zoey

(Unassigned)

Confirmed

(Unassigned)

26.2 Snapshot 2, 26.1.2

Retrieved