Posted August 21, 201312 yr 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?
August 21, 201312 yr 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)
August 23, 201312 yr Author -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?
August 23, 201312 yr 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.