Jump to content

[1.8.9] WorldSavedData not executing readFromNBT [SOLVED]


Recommended Posts

Posted

What would cause #readFromNBT to not be called?

 

I have a class that extends WorldSavedData and that class overrides both writeToNBT and readFromNBT.

 

get method

public static WorldData get(World world)
{
	WorldData data = (WorldData) world.loadItemData(WorldData.class, IDENTITY);
	if(data == null)
	{
		data = new WorldData();
		world.setItemData(IDENTITY, data);
	}
	return data;
}

 

I use the get method and call #markDirty().  It then runs through #writeToNBT and I store data within the nbt.  I am fairly certain it is writing data correctly, but for some unknown reason, #readFromNBT is never called.

 

Am I suppose to register my class somewhere or...

 

Thanks!

Posted

While debugging, I have a breakpoint at where #readFromNBT starts.  Nothing ever happens for me there.  I run it in debug mode.

 

//Instead of this
NBTTagList list = nbt.getTagList(IDENTITY, NBT.TAG_LIST);

//I should do this?
NBTTagList list = nbt.getTagList(IDENTITY, NBT.TAG_COMPOUND);
//Because the integer passed is the type of NBT's the list is holding?

 

Thanks for clarifying that bit up, was a little bit confused as to how that worked:)

Posted

Yep, in your case (which is the typical case), you should use NBT.TAG_COMPOUND when retrieving your list.

 

If your #readFromNBT is never getting called, is your static #get method ever called? How about #writeToNBT?

 

Also, I'm a little dubious about your use of long as a storage method for potentially an entire chunk's worth of data... while it may work most of the time if you generally need to store only a few positions per chunk, it seems extremely fragile to me for very little benefit. Of course, I don't know the whole story, so maybe you will only ever have 1 or 2 positions per chunk and that's fine, but something to consider.

Posted

I do call the #get method.  After marking it dirty and it saves, #writeToNBT is called.

 

I have a hierarchy of lists within lists...  This is saved within nbt in a long.

 

The chunk requires about 48 bits, (22 bits x coord, 22 bits z coord, 4 bits dimension) in order to cover the Minecraft world of chunks and in which dimension they belong.  Then, within the chunk, I store the x, y, and z coords (4 bits, 8 bits, 4 bits), taking up a total of 64 bits. (During ram usage)

So, in other words, A chunk needs 48 bits, and each block within needs 16.

 

I do see your point on storing a long within the nbt...  I'll work on that after getting the #readFromNBT to work.  Perhaps I just need to update my forge version.

 

I'll mess around with the code a little bit.

 

Thanks for the help thus far.

Posted

Am I suppose to call the get method in order for it to run #readFromNBT?  I do call it, but is there a certain place that I'm suppose to do that?

 

Also, I get this error

 

 

 

[03:54:14] [server thread/INFO] [FML]: Loading dimension 0 (New World) (net.minecraft.server.integrated.IntegratedServer@359173ac)
[03:54:14] [server thread/INFO] [FML]: Loading dimension 1 (New World) (net.minecraft.server.integrated.IntegratedServer@359173ac)
[03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: java.lang.RuntimeException: Failed to instantiate class MCO.World.WorldData
[03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at net.minecraft.world.storage.MapStorage.loadData(MapStorage.java:59)
[03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at MCO.World.WorldData.get(WorldData.java:26)
[03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at MCO.Events.PlayerEvents.worldEvent(PlayerEvents.java:433)
[03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_6_PlayerEvents_worldEvent_Load.invoke(.dynamic)
[03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:49)
[03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:140)
[03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at net.minecraft.server.integrated.IntegratedServer.loadAllWorlds(IntegratedServer.java:100)
[03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at net.minecraft.server.integrated.IntegratedServer.startServer(IntegratedServer.java:127)
[03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:508)
[03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at java.lang.Thread.run(Unknown Source)
[03:54:14] [server thread/INFO] [sTDERR]: [java.lang.Throwable:printStackTrace:-1]: Caused by: java.lang.NoSuchMethodException: MCO.World.WorldData.<init>(java.lang.String)
[03:54:14] [server thread/INFO] [sTDERR]: [java.lang.Throwable:printStackTrace:-1]: 	at java.lang.Class.getConstructor0(Unknown Source)
[03:54:14] [server thread/INFO] [sTDERR]: [java.lang.Throwable:printStackTrace:-1]: 	at java.lang.Class.getConstructor(Unknown Source)
[03:54:14] [server thread/INFO] [sTDERR]: [java.lang.Throwable:printStackTrace:-1]: 	at net.minecraft.world.storage.MapStorage.loadData(MapStorage.java:55)
[03:54:14] [server thread/INFO] [sTDERR]: [java.lang.Throwable:printStackTrace:-1]: 	... 9 more
[03:54:14] [server thread/INFO] [FML]: Loading dimension -1 (New World) (net.minecraft.server.integrated.IntegratedServer@359173ac)
[03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: java.lang.RuntimeException: Failed to instantiate class MCO.World.WorldData
[03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at net.minecraft.world.storage.MapStorage.loadData(MapStorage.java:59)
[03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at MCO.World.WorldData.get(WorldData.java:26)
[03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at MCO.Events.PlayerEvents.worldEvent(PlayerEvents.java:433)
[03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_6_PlayerEvents_worldEvent_Load.invoke(.dynamic)
[03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:49)
[03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:140)
[03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at net.minecraft.server.integrated.IntegratedServer.loadAllWorlds(IntegratedServer.java:100)
[03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at net.minecraft.server.integrated.IntegratedServer.startServer(IntegratedServer.java:127)
[03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:508)
[03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at java.lang.Thread.run(Unknown Source)
[03:54:14] [server thread/INFO] [sTDERR]: [java.lang.Throwable:printStackTrace:-1]: Caused by: java.lang.NoSuchMethodException: MCO.World.WorldData.<init>(java.lang.String)
[03:54:14] [server thread/INFO] [sTDERR]: [java.lang.Throwable:printStackTrace:-1]: 	at java.lang.Class.getConstructor0(Unknown Source)
[03:54:14] [server thread/INFO] [sTDERR]: [java.lang.Throwable:printStackTrace:-1]: 	at java.lang.Class.getConstructor(Unknown Source)
[03:54:14] [server thread/INFO] [sTDERR]: [java.lang.Throwable:printStackTrace:-1]: 	at net.minecraft.world.storage.MapStorage.loadData(MapStorage.java:55)
[03:54:14] [server thread/INFO] [sTDERR]: [java.lang.Throwable:printStackTrace:-1]: 	... 9 more
[03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: java.lang.RuntimeException: Failed to instantiate class MCO.World.WorldData
[03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at net.minecraft.world.storage.MapStorage.loadData(MapStorage.java:59)
[03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at MCO.World.WorldData.get(WorldData.java:26)
[03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at MCO.Events.PlayerEvents.worldEvent(PlayerEvents.java:433)
[03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_6_PlayerEvents_worldEvent_Load.invoke(.dynamic)
[03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:49)
[03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:140)
[03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at net.minecraft.server.integrated.IntegratedServer.loadAllWorlds(IntegratedServer.java:100)
[03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at net.minecraft.server.integrated.IntegratedServer.startServer(IntegratedServer.java:127)
[03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:508)
[03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at java.lang.Thread.run(Unknown Source)
[03:54:14] [server thread/INFO] [sTDERR]: [java.lang.Throwable:printStackTrace:-1]: Caused by: java.lang.NoSuchMethodException: MCO.World.WorldData.<init>(java.lang.String)
[03:54:14] [server thread/INFO] [sTDERR]: [java.lang.Throwable:printStackTrace:-1]: 	at java.lang.Class.getConstructor0(Unknown Source)
[03:54:14] [server thread/INFO] [sTDERR]: [java.lang.Throwable:printStackTrace:-1]: 	at java.lang.Class.getConstructor(Unknown Source)
[03:54:14] [server thread/INFO] [sTDERR]: [java.lang.Throwable:printStackTrace:-1]: 	at net.minecraft.world.storage.MapStorage.loadData(MapStorage.java:55)
[03:54:14] [server thread/INFO] [sTDERR]: [java.lang.Throwable:printStackTrace:-1]: 	... 9 more

 

 

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I need to know what mod is doing this crash, i mean the mod xenon is doing the crash but i want to know who mod is incompatible with xenon, but please i need to know a solution if i need to replace xenon, i cant use optifine anymore and all the other mods i tried(sodium, lithium, vulkan, etc) doesn't work, it crash the game.
    • I have been trying to solve a consistent crashing issue on my brother's computer where it will crash during the "Scanning Mod Candidates" phase of the loading process that starts when you click the play button on the Minecraft launcher. The issue seems to stem from a missing library that it mentions in the log file I provide below. I might I'm missing the bigger issue here for a smaller one but hopefully someone can find what I'm missing. Here's all of the stuff that I've been able to figure out so far: 1. It has nothing to do with mods, the crash happened with a real modpack, and even when I made a custom modpack and launched it without putting ANY mods into it (That is where the log file comes from by the way). 2. I have tried to find this class like a file in the Minecraft folders, but I've had no luck finding it (I don't think it works like that, but since I really don't understand how it works, I just figured I'd try). 3. I haven't seen anyone else have this issue before. 4. I know that my modpack (with mods) does work since I've run it on my computer, and it works fantastic. For some reason my brother's computer can't seem to run anything through curseforge. 5. This is for Minecraft version 1.20.1, Minecraft launcher version 3.4.50-2.1.3, forge 47.3.0, and curseforge app version 1.256.0.21056 6. My brother is using a Dell laptop from 6 years ago running Windows 10 (If you think more info on this would help, please ask as I do have it. I'm just choosing not to put it here for now). 7. I have reinstalled the curseforge app and installed Minecraft version 1.20.1. I have not reinstalled Minecraft or forge 47.3.0 but I didn't know if that would help. 8. I had an error code of 1 Please let me know if there is anything else that I am missing that you would like me to add to this post/add in a comment! Lastly, many thanks in advance to whoever can help! ------------- LOG FILE (latest.log) ------------- (from /Users/<NAME OF USER>/cursforge/minecraft/Instances/<THE NAME OF MY EMPTY MODPACK>/logs/latest.log) (This was made after running an empty modpack with same versions for all apps) ("[REDACTED]" is not the actual text from the log, it is me replacing text I figured wouldn't be necessary for fixing and would hurt my privacy) https://pastebin.com/hxXvGGEK ------------- DEBUG.LOG (I realized that I should have put this here first after I had done all of the work on putting latest.log in) -------------------- (again, "[REDACTED]" is not the actual text from the log, it is me replacing text I figured wouldn't be necessary for fixing and would hurt my privacy) https://pastebin.com/Fmh8GHYs
    • Pastebin... https://pastebin.com/Y3iZ85L5   Brand new profile, does not point to a mod as far as I can tell, my fatal message just has something about mixins. Don't know much about reading logs like this, but am genuinely stuck, please help. Java updated, pc restarted.
    • I was playing minecraft, forge 47.3.0 and 1.20.1, but when i tried to play minecraft now only crashes, i need help please. here is the crash report: https://securelogger.net/files/e6640a4f-9ed0-4acc-8d06-2e500c77aaaf.txt
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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