-
-
Notifications
You must be signed in to change notification settings - Fork 186
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?
pumpkin-nbt/src/nbt_compress.rs
Outdated
compound.put_int("test_value", 12345); | ||
|
||
// Create a temporary file path | ||
let path = Path::new("test_nbt_file.dat"); |
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.
You should use the temp file crate for this
pumpkin/src/server/mod.rs
Outdated
@@ -137,6 +141,10 @@ impl Server { | |||
server_listing: Mutex::new(CachedStatus::new()), | |||
server_branding: CachedBranding::new(), | |||
bossbars: Mutex::new(CustomBossbars::new()), | |||
player_data_storage: ServerPlayerData::new( | |||
format!("./{world_name}/playerdata"), |
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.
I'm not comfortable with this being a solo relative path. I know that our world is relative to where we execute the server, but having "magic string" like this, even if is correct now can cause issues in the future if there are refactors.
Could you make a get_world_path
or something on the config instance, then pass that here and to our world loading?
What if the program panics / crashes, and we can't handle leaving or the server shutting down? |
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