Jump to content

WorldSavedData extended class isn't saving?


Recommended Posts

So I have a list of locations called myBlockPos.  myBlockPos has private variables named, BlockPos, IBlockState, and int.  It is used to let blocks respawn in said locations.  While in the game, I use a command, fill in the required information, and store it in myBlockPos.


Now to the problem.  It doesn't save.  Data is added, I set the instance's dirty boolean to true, but after I reset minecraft, it isn't there anymore... In other words, the get method doesn't find anything with the given identifier and it creates a brand new instance.






Current classes:







Link to comment
Share on other sites

You are always using the client world in your command. Of course this world will never save. You must use the World from the ICommandSender.


That deffinately did something.  I debugged and it walked through all the saving of the class after I set it dirty.  It then set the dirty boolean back to false.  I believe my event handler is wrong now.  Any Ideas?


This is the event now.  It doesn't find anything in the get method with the given identifier and world.



Thank you for everything you've done.

Link to comment
Share on other sites

Okay.  I removed the event.  When I run the command for the first time, it creates a new instance of WorldData, adds information to it, then sets it dirty.  I save and quit the game.


The second time, it still creates a new instance.  Is that suppose to happen?  It doesn't have any data stored in it, nor does readFromNBT get called.

Link to comment
Share on other sites

I was about to update my last reply, but realized your prompt response.  I appreciate that!


Very strange, It seems that it is running through the read method now.  One moment while I look at it please!


Got it working!  For the most part.  Just a quick question though if you don't mind.


I have a for loop to go through my list of data.

for(int i = 0; nbt.getIntArray("myBlockPos" + i) != null; i++){

//obtain info



nbt.getIntArray never returns null though.  Is there another way to check if it contains no information?

Link to comment
Share on other sites

Store your block positions in an NBTTagList, then you can iterate through that instead. Or use nbt.hasKey("yourKey") as your loop condition.


Hey coolAlias!  I was wondering when you'd show up:p

Thanks again for your help, and thanks for the tutorial on IEEP.  It's gotten me thus far.

As for your tip, it worked wonders.


And thanks diesieben07, I very greatly appreciate all the help you have given me throughout this learning experience.


I'll be back sooner or later.  Haha.


For those that are reading this, I have updated those pastebin Links to show what Is currently working for me.  buh bye.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Create New...

Important Information

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