-
-
Notifications
You must be signed in to change notification settings - Fork 200
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
feat(player-data): Support saving and loading player NBT Data #600
base: master
Are you sure you want to change the base?
Conversation
Why not move the nbt data into the hunger manager |
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.
Why do we now save player data periodically? Isn't saving when players leave enough?
What if the program panics / crashes, and we can't handle leaving or the server shutting down? |
I see you created |
2010a10
to
f7f50fc
Compare
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.
Looks good really good! Other than a couple spots I mentioned, its easy to follow too.
Maybe also include a Java player nbt file in an assets folder and test if we can de serialize that?
let uuid_copy = *uuid; | ||
let data_clone = data; | ||
|
||
match tokio::spawn(async move { |
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.
Why are we spawning a tokio task here? No async code is used
|
||
// Offload file I/O to a separate tokio task | ||
let uuid_copy = *uuid; | ||
let nbt = tokio::task::spawn_blocking(move || -> Result<NbtCompound, PlayerDataError> { |
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.
Why are we spawning a tokio task here? No async code is used
5102893
to
39e551e
Compare
Description
This PR adds the must-have feature to save and load player NBT Data !
This code actually does:
This code also contains a rework of the experience packet and health packet with
tick_experience
andtick_health
; this is needed with how NBT data are handled before player spawning in the world. Like that, we send experience, health, ... directly on the first player tick and send them when there is an update like before.I also added some data to NBT, like gamemode, or food, and impl them in the code to use them now instead of default data. Now the future part needed for this code is the implementation of other NBT values accessible from https://minecraft.wiki/w/Player.dat_format
Testing
I have tested to move on the map, give experience, change gamemode, ... stopping the server and joining again and all is working good. May need more test from others !
Please follow our Coding Guidelines