Jump to content

WorldSavedData


SirXenophon

Recommended Posts

I want to create a WorldSavedData object that records information that may happen as frequently as once every few seconds (let's say an object that records how many times a player has jumped since world creation, for example). I have the class for my WorldSaveData object written, including all of the appropriate methods (e.g. readFromNBT, writeToNBT, and mutator methods for updating the variables in my object). I am able to access the object using the static get method, and have subscribed an event handler for dealing with my event (player jumping, for example). Also, after the event handler has called the mutator method to update the variable, the WorldSavedData is marked as dirty.

 

However, when I try to use the event handler to update my object (the number of times a player has jumped) it doesn't seem to update the correct value. It seems that the variable has not yet been saved to the NBT format and so I'm only able to access the last-saved number of jumps the player has made.

 

Is there a way to force the game to call the writeToNBT method after updating my variable? Is this even desirable? Or is there some other way of achieving my goal that I have overlooked?

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

×
×
  • Create New...

Important Information

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