Jump to content

[Unsolved] Save Data Separate from World (i.e in saves/world/data/myfile.dat)


Recommended Posts

Posted

I have some NBT data I want to save to .minecraft/saves/<world>/data/myfile.dat.  How would I do that?  I couldn't find out with google or the forge javadocs.  Do I just open a binary file and write the nbt in binary or does Forge have a function I should call?

 

Thanks,

electrodude

 

EDIT:  Also, how can I make it so this data gets loaded and saved automatically (i.e. by calling my object's readFromNBT and writeToNBT methods) on world load and save/quit?

Posted

here is the information that I found useful when I made my implementation of saving to world save folder....

 

http://www.minecraftforge.net/forum/index.php?topic=8520.0

 

https://github.com/diesieben07/Questology/blob/e9f46d8b3aa41b82f9021c892bca7ee558e7899a/source/demonmodders/questology/QuestologyWorldData.java

 

and... my implementation..with load/save stuff

 

https://github.com/shadowmage45/AncientWarfare/tree/master/AncientWarfare/src/shadowmage/ancient_warfare/common/tracker

(hint...load/save are handled mostly automatically whenever the world loads/saves, you just need to make sure you keep the data up-to-date)

 

Oh hey...Hi diesieben07 :)    hope you don't mind I used your previous example(s) :)

 

Posted

-snip-

 

Thanks!  I looked at your code and that's exactly what I want!  The only question I have left (that I know of atm) is, how is your tracker told to load data (by making a new AWGameData()) on world load?  When is GameDataTracker.handleWorldLoad(World world) called?

Posted

That method is called from my event handler, from the worldLoad event:

 

@ForgeSubscribe
public void onWorldLoad(WorldEvent.Load evt)
  {
  if(evt.world instanceof WorldServer)
    {
    GameDataTracker.instance().handleWorldLoad(evt.world);
    }  
  }

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.

Announcements



×
×
  • Create New...

Important Information

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