-
-
Notifications
You must be signed in to change notification settings - Fork 81
feature/network_nbt #263
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
Merged
Sweattypalms
merged 14 commits into
ferrumc-rs:master
from
MSKatKing:feature/network-nbt
Nov 24, 2025
Merged
feature/network_nbt #263
Sweattypalms
merged 14 commits into
ferrumc-rs:master
from
MSKatKing:feature/network-nbt
Nov 24, 2025
Conversation
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
Contributor
Author
|
Can confirm it works, I tested it with the play Disconnect packet and the packet sent as normal and the client recognized it and displayed the correct message. |
Sweattypalms
requested changes
Nov 24, 2025
MSKatKing
commented
Nov 24, 2025
Sweattypalms
approved these changes
Nov 24, 2025
Member
Sweattypalms
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.
lgtm
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.
I've implemented
NetEncodeandNetDecodefor NBT types. Here's how it works:We have a struct, NBT, which is just a wrapper around T.
This type, when T: NBTSerializable, implement NetEncode. The NBTSerializable trait has been modified to use a
std::io::Writeinstead of a hard-coded Vec. It's also been given an async version of the serialize fn. The NetEncode implementation basically just calls these functions for T.NBT also implements NetDecode when T: for<'a> FromNbt<'a>. NetDecode works a little differently. It will first read the data into a Vec, then create a new
NbtTape, finally using that to deserialize into T.NBT implements Deref<Output=T> and DerefMut, so you can access fields of T without unwrapping it. To use it, just place NBT on the packet field you want to have serialized/deserialized to/from NBT.
This is still a draft PR because I have not tested it yet. Once I know it works, I'll submit this for review.