fix(ray_trace): don't bail out of blockAtEntityCursor when yaw or pitch is 0 - #3962
Open
Xuxchloris wants to merge 1 commit into
Open
fix(ray_trace): don't bail out of blockAtEntityCursor when yaw or pitch is 0#3962Xuxchloris wants to merge 1 commit into
Xuxchloris wants to merge 1 commit into
Conversation
…ch is 0 blockAtEntityCursor used truthiness checks on entity.yaw / entity.pitch, so a legitimate orientation of exactly 0 (e.g. facing -Z, or looking level) was treated as missing and the ray trace was skipped, returning null. Use null checks instead so 0 is a valid angle while truly missing values still short-circuit. Fixes PrismarineJS#3935. Adds internal tests covering yaw=0 (facing -Z), pitch=0 (facing +X) and missing yaw/pitch across all tested versions; the ray targets are placed as 3-block columns so the assertions are robust to eye-height variation.
Xuxchloris
force-pushed
the
fix/blockAtEntityCursor-zero-angles
branch
from
August 14, 2026 19:55
84dd277 to
e128c15
Compare
Author
|
Heads-up on the failing "MC 1.21.8 1.21.9 1.21.11" job (I can't view its logs without admin rights, so here's the evidence I have):
Could you re-run the job? Happy to dig further if it still fails. |
Author
|
Update: the updated commit (e128c15) now passes all 11 checks — the earlier "MC 1.21.8 1.21.9 1.21.11" failure did not reproduce. No rerun needed. 👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3935.
Problem
blockAtEntityCursor()validatedentity.yaw/entity.pitchwith truthiness checks, so a legitimate orientation of exactly0(facing -Z, or looking level) was treated as missing and the ray trace was skipped — the function returnednulleven though the entity orientation was valid.Change
lib/plugins/ray_trace.js: use null checks (entity.pitch == null || entity.yaw == null) so0is a valid angle while truly missing values still short-circuit.Tests
Added to
test/internalTest.js(run across all tested versions):yaw === 0(facing -Z) returns the block in front.pitch === 0(facing +X) returns the block in front.yaw/pitchstill returnsnull.Verification
mocha test/internalTest.js --grep blockAtEntityCursor— 81/81 passing (3 tests × 27 supported versions).standardlint clean.