Fix lpVec3 packet endianness#1506
Open
GenerelSchwerz wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes lpVec3 encoding/decoding to match Minecraft’s on-wire big-endian 32-bit word layout (preventing silent corruption of nonzero velocity vectors on 1.21.9+), and adds regression coverage using real 1.21.11 payloads.
Changes:
- Switch
lpVec3read/write of the 32-bit portion to big-endian and align byte layout withpacked = c << 16 | b << 8 | a. - Refactor packing/unpacking bit extraction to avoid 32-bit bitwise truncation.
- Add mocha tests covering zero-vector decoding and byte-exact round-trips of captured vanilla payloads.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/datatypes/lpVec3.js | Updates lpVec3 serialization/deserialization to big-endian and adjusts packing/unpacking implementation. |
| test/lpVec3Test.js | Adds targeted decode + exact round-trip tests using real 1.21.11 payloads. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Author
|
Failing tests are redundant there, its the fault of the test, not me. |
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.
Problem
lpVec3reads and writes its 32-bit word as little-endian, while Minecraft usesFriendlyByteBuf.readUnsignedInt/writeInt(big-endian). This silently corrupts nonzero entity velocity vectors on 1.21.9+.Fix
vec3i16using Add feature flag for lpVec3 entity velocity minecraft-data#1206.This is an alternative to #1494: it keeps protocol datatype units native instead of converting
lpVec3into legacy 1/8000 units.Validation
npx standard src/datatypes/lpVec3.js test/lpVec3Test.jsnpx mocha test/lpVec3Test.js