Posted September 27, 201510 yr I don't see the NBT data folder "civilization" for my mod anywhere when I open a save in NBTExplorer. Why isn't it saving? https://github.com/deletethis-github/Civilization/blob/master/src/main/java/deletethis/civilization/CivilizationWorldData.java https://github.com/deletethis-github/Civilization/blob/master/src/main/java/deletethis/civilization/event/WorldLoadEventHandler.java
September 27, 201510 yr I forgot to register the event Edit: Only problem is, when a world is first loaded, my code is creating four town tag compounds when there should only be one, and every time I load up the world again, that amount multiplies and it's at 60 now. I think there is something seriously wrong with how I have coded this. Edit: Ok...I fixed the duplication by clearing the TownManager towns ArrayList every time the world is loaded, right before I populate the list. I am still not sure if this is the best way to do this, I am not a very good programmer. Is the TownManager code supposed to be run on serverside only?
September 27, 201510 yr Ok, I refactored a bit and fixed my previous issues. But, my WorldSavedData is only being saved to the overworld dimension data, not to the nether or end. Why is this happening? Each dimension is its own World class, and therefore should be getting its own WorldSavedData, right? Here is the class where I load up the WorldSavedData whenever a dimension loads https://github.com/deletethis-github/Civilization/blob/master/src/main/java/deletethis/civilization/event/WorldLoadEventHandler.java
September 27, 201510 yr If you use World.mapStorage (which you implicitly do if you use the methods directly in world) your data is global for the whole save file. It will be stored in the overworld folder but will be available to all dimensions as one instance. If you use World.perWorldStorage instead there will be one instance of your data per dimension. Ohhh Perfect, thanks
September 28, 201510 yr Ok, I am puzzled once again. Relevant classes Town.java: A data structure representing a town https://github.com/deletethis-github/Civilization/blob/master/src/main/java/deletethis/civilization/Town.java CivilizationWorldData.java: Manages an ArrayList of Towns and loads/writes Town NBT from/to disk https://github.com/deletethis-github/Civilization/blob/master/src/main/java/deletethis/civilization/world/CivilizationWorldData.java WorldLoadEventHandler.java: Tells worlds to load CivilizationWorldData whenever a world is loaded https://github.com/deletethis-github/Civilization/blob/master/src/main/java/deletethis/civilization/event/WorldLoadEventHandler.java ItemFoundingBook.java: Attempts to create a world when right clicked by calling CivilizationWorldData.addTown(Town town) https://github.com/deletethis-github/Civilization/blob/master/src/main/java/deletethis/civilization/item/ItemFoundingBook.java Description of the intent of the code and the problem encountered When a world is loaded, WorldLoadEventHandler will tell the world to load CivilizationWorldData, causing it to read relevant town NBT and create and add Town objects to its internal ArrayList<Town> towns. Upon creating a new town via ItemFoundingBook, everything works properly at first. You use it once, and the Town object is created and added to the ArrayList<Town> towns. It is also saved to disk when pausing the game. You are unable to create another town of the same name, because it is already in the ArrayList<Town> towns. HOWEVER, when exiting out of the world and then entering it again, it is reset back to square one. You are able to create another town of the same name again, even though it is already on disk. It is as if the ArrayList<Town> towns is not being initialized up when a world loads, even though the code for doing that exists in CivilizationWorldData.readFromNBT(NBTTagCompound nbt). The code is there, why isn't it reading the NBT from the world and filling out the ArrayList<Town> towns when the world is told to load the CivilizationWorldData?
September 28, 201510 yr Thanks https://github.com/deletethis-github/Civilization/commit/144e25c1caeb2ae1d4fc2a4a8b97ef009018379c
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.