Skip to content

Conversation

@brentspine
Copy link

@brentspine brentspine commented Dec 16, 2025

@brentspine
Copy link
Author

brentspine commented Dec 16, 2025

@copilot Review ? (idk if it works like that)

Copy link
Contributor

Copilot AI left a 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 toSignedByte utility 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.

Comment on lines +7 to +10
const toSignedByte = (value) => {
const byte = value & 0xff
return byte > 127 ? byte - 256 : byte
}
Copy link

Copilot AI Dec 16, 2025

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.

Copilot uses AI. Check for mistakes.
Copy link
Author

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

@extremeheat
Copy link
Member

Thanks

Copy link
Member

@extremeheat extremeheat left a 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+
Copy link
Member

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

@extremeheat
Copy link
Member

@extremeheat extremeheat marked this pull request as draft January 26, 2026 04:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error with signed chat: RangeError [ERR_OUT_OF_RANGE]

2 participants