Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.16.5] How to sync player custom persistent data?


 Share

Recommended Posts

Hi! I add a value (e.g. 10) to player's custom persistent data variable and print it out. It's the same on server and client until I exit the world. If I reopen the game (or load the world) the value is still there on server, but on client it's 0. My TileEntity screen gets the value from the player and displays it. But it gets the value only on client which is not the correct value. How to sync this value/variable after I reopen the game/world?

I have tried to add a DataParameter to PlayerEntity and use the entityDataManager in the PlayerTickEvent function, but it crashed the game. It's probably not the right way to do it. Any ideas? Thanks.

Link to comment
Share on other sites

I think you need PlayerLoggedInEvent and send a packet to the client to synchronise data. Probably you also need to do this in PlayerChangedDimensionEvent and PlayerEvent.PlayerRespawnEvent.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.