Jump to content

Saving custom world data on server side


colinvella

Recommended Posts

WorldSavedData is your friend.

You can find an (old but still applicable) example here.

The version there will keep one instance of your data per save file. If you wish to have one instance per dimension instead, use

world.perWorldStorage.loadData

instead here and

world.perWorldStorage.setData

instead here.

 

To store data, just create normal fields in that WorldSavedData class (e.g. if you wish to store a String, make a field of type String). Then read and write this data to NBT in the appropriately named methods. Also remember to call

markDirty

on your WorldSavedData instance whenver you change any data in it, otherwise Minecraft will not save it to disk.

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.



×
×
  • Create New...

Important Information

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