Fix blockAtEntityCursor returning null when yaw or pitch is 0 - #3970
Open
SirYadav1 wants to merge 1 commit into
Open
Fix blockAtEntityCursor returning null when yaw or pitch is 0#3970SirYadav1 wants to merge 1 commit into
SirYadav1 wants to merge 1 commit into
Conversation
…rineJS#3935) The truthiness check (!entity.yaw / !entity.pitch) treated a legitimate zero value as missing, causing the ray trace to be skipped and the function to incorrectly return null. Use null checks (== null) instead so yaw=0 / pitch=0 are valid. Fixes PrismarineJS#3935
SirYadav1
force-pushed
the
fix/blockAtEntityCursor-zero-yaw-pitch
branch
from
August 18, 2026 16:53
88fbb85 to
3b88ad6
Compare
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
bot.blockAtEntityCursor()(andblockAtCursor) incorrectly returnednullwhenever the entity hadyaw === 0orpitch === 0, because the guard used truthiness checks (!entity.yaw/!entity.pitch). A value of0is a perfectly valid orientation (e.g. looking level =pitch 0, facing north =yaw 0), so the ray trace was being skipped.Change
lib/plugins/ray_trace.js— replaced the truthiness guard with explicit null checks:Test
Added
blockAtEntityCursor handles zero yaw and pitch (#3935)totest/internalTest.js. It places a column of gold blocks in the cursor direction, setsyaw = 0andpitch = 0, and asserts the block is returned. The test fails on the old code (returns null) and passes on the fix, across all tested versions (1.21.4 – 26.1).Verification
Also verified against a live 1.21.11 Paper server (
intel-node2.zyphron.cloud:20013): with the fix the ray cast is actually executed instead of early-returning.