Skip to content

fix(ray_trace): don't bail out of blockAtEntityCursor when yaw or pitch is 0 - #3962

Open
Xuxchloris wants to merge 1 commit into
PrismarineJS:masterfrom
Xuxchloris:fix/blockAtEntityCursor-zero-angles
Open

fix(ray_trace): don't bail out of blockAtEntityCursor when yaw or pitch is 0#3962
Xuxchloris wants to merge 1 commit into
PrismarineJS:masterfrom
Xuxchloris:fix/blockAtEntityCursor-zero-angles

Conversation

@Xuxchloris

Copy link
Copy Markdown

Fixes #3935.

Problem

blockAtEntityCursor() validated entity.yaw / entity.pitch with truthiness checks, so a legitimate orientation of exactly 0 (facing -Z, or looking level) was treated as missing and the ray trace was skipped — the function returned null even though the entity orientation was valid.

Change

lib/plugins/ray_trace.js: use null checks (entity.pitch == null || entity.yaw == null) so 0 is 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.
  • Missing yaw/pitch still returns null.

Verification

  • mocha test/internalTest.js --grep blockAtEntityCursor — 81/81 passing (3 tests × 27 supported versions).
  • standard lint clean.

…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
Xuxchloris force-pushed the fix/blockAtEntityCursor-zero-angles branch from 84dd277 to e128c15 Compare August 14, 2026 19:55
@Xuxchloris

Copy link
Copy Markdown
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.

@Xuxchloris

Copy link
Copy Markdown
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. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

blockAtEntityCursor() incorrectly returns null if either yaw or pitch are 0

1 participant