Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-264176

The predicate "looking_at" does not work as expected

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • None
    • 1.20.1
    • None
    • OS: Windows 11 64bit
      Java version: jdk17.0.7
      Minecraft version: 1.20.1
    • Unconfirmed
    • (Unassigned)

      Description

      I encountered unexpected behavior when testing the "looking_at" predicate using the command /execute if predicate test:test (with the attached map with datapack). 

      Observed behavior

      • If I could see the target entity’s eyes (the EyePos point, not the eye on the texture), even if I was looking at the entity through a solid block, the “look_at” test passed (IMG1).
      • However, if I couldn’t see the entity’s eyes, even if I was looking at the entity, the test failed (IMG2).

      Expected behavior

      The "look_at" test should only pass when the player directly looks at the target entity without obstructions.

      Steps to reproduce

      1. Download the attached map with datapack.
      2. Launch the game and play the map.
      3. Execute /execute if predicate test:test in the above situations.

      Additional information

      The bug might affect all versions since "look_at" is added to the game (Tested on 1.20.1).
      I believe this issue may be related to how Minecraft determines whether an entity is visible (not blocked by blocks, etc.). Minecraft’s raycast can only detect one type of collision (entity or block) at a time. So, the game must first run an entity collision test and then a block collision test, which uses a strange method to detect blocks (it simply detects block collisions on the line between the player’s eye position and the target entity’s eye position!!). This means that if you can see the target entity’s eye (EyePos) and you are targeting it, regardless of whether you are looking through a block or not, the test will give you a pass!

        1. IMG1.png
          IMG1.png
          527 kB
        2. IMG2.png
          IMG2.png
          508 kB
        3. looking_at_Test_Map.zip
          866 kB

            Unassigned Unassigned
            growuphappily growuphappily
            Votes:
            3 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: