-
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
- Download the attached map with datapack.
- Launch the game and play the map.
- 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!
- duplicates
-
MC-226487 looking_at subpredicate doesn't always detect visible entities
- Resolved