-
Notifications
You must be signed in to change notification settings - Fork 115
First pass ext-encoding support #322
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
Conversation
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 first pass support for ext-encoding in the BedrockProtocol library. The primary purpose is to migrate from the previous PacketSerializer system to a new encoding system using pmmp/encoding library, which provides better performance and more structured data serialization.
Key changes include:
- Replace PacketSerializer with ByteBufferReader/ByteBufferWriter throughout the codebase
- Migrate to pmmp/encoding library for binary data operations (LE, VarInt, Byte, etc.)
- Introduce CommonTypes class to centralize common serialization operations
Reviewed Changes
Copilot reviewed 300 out of 356 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
Many entity type files | Update serialization methods to use new encoding system |
Camera-related types | Migrate to ByteBufferReader/ByteBufferWriter |
Biome generation types | Convert to pmmp/encoding format |
Core packet types | Update to use CommonTypes and new buffer system |
Serializer components | Replace PacketSerializer with CommonTypes utilities |
Multiple packet classes | Implement new encoding/decoding with ByteBufferReader/Writer |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
The current game plan is to roll out BedrockProtocol only with ext-encoding first. This ensures that if there are any major issues that my (extensive) unit tests haven't caught, the damage will be limited to packet encoding, so no permanent damage will be done. Since we use NBT in world saves as well as on the network, depending on the version using ext-encoding here would make this next upgrade very risky, so it's not worth it for now. The time for that will come in the next month or two.
7475989
Main changes:
PacketSerializer
is removed, all encode/decode methods previously in there are now static methods ofCommonTypes
DataPacket->decode()
now acceptspmmp\encoding\ByteBufferReader
DataPacket->encode()
now acceptspmmp\encoding\ByteBufferWriter
ext-encoding
APIsQuestions/concerns/doubts:
CommonTypes
being static.CommonTypes::writeString($out, $string)
is more boilerplaty than$out->writeString($string)
CommonTypes
doesn't need to be static.PacketSerializer
to customise packet decoding? but we were mostly gravitating towardsfinal
type classes having their own static::read()
and->write()
methods anyway...CommonTypes::writeOptional()
looks nasty for objects and could be made prettierext-encoding
with the static API.