-
-
Notifications
You must be signed in to change notification settings - Fork 260
Implement signed byte conversion for checksum to fix #3765 #1442
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
@copilot Review ? (idk if it works like that) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements signed byte conversion for chat checksums to fix issue #3765. The Minecraft 1.21.5+ protocol expects checksums to be signed bytes (range -128 to 127) rather than unsigned bytes (range 0-255), which was causing protocol validation issues.
- Adds a
toSignedByteutility function to convert unsigned bytes to signed bytes - Applies the conversion to the checksum field in chat command packets for version 1.21.5+
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const toSignedByte = (value) => { | ||
| const byte = value & 0xff | ||
| return byte > 127 ? byte - 256 : byte | ||
| } |
Copilot
AI
Dec 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider moving the toSignedByte function to src/datatypes/checksums.js and exporting it alongside computeChatChecksum. This would improve code organization by grouping related checksum functionality together and make the function reusable if needed elsewhere. The function is specifically designed to handle the signed byte requirement for checksums in the Minecraft protocol.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot coauthor pr #1442 based on this this feedback
|
Thanks |
extremeheat
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please review comment
| argumentSignatures: canSign ? signaturesForCommand(command, options.timestamp, options.salt, options.preview, acknowledgements) : [], | ||
| messageCount: client._lastSeenMessages.pending, | ||
| checksum: computeChatChecksum(client._lastSeenMessages), // 1.21.5+ | ||
| checksum: toSignedByte(computeChatChecksum(client._lastSeenMessages)), // 1.21.5+ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This branch specifically covers the chat commands only. Is this intentional? Your linked issue PrismarineJS/mineflayer#3765 seems to hint at normal chat messages too
|
It's also already clamped here https://github.com/PrismarineJS/node-minecraft-protocol/blob/master/src/datatypes/checksums.js#L16 |
Fix PrismarineJS/mineflayer#3765