Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.8.9] WorldSavedData not executing readFromNBT [SOLVED]


Atijaf
 Share

Recommended Posts

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!

Link to comment
Share on other sites

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:)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

 

 

Link to comment
Share on other sites

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
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.

 Share



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • I have my structure in .nbt format. When I click with my custom item on the ground it should place the structure. However, it only places one block from the bottom corner of the structure. When I try to walk, the player moves very slowly, like the wall structure is there. For some reason it's just not visible. After reopening the world, the structure is visible. My code:  if (world instanceof ServerLevel _serverworld) { StructureTemplate template = _serverworld.getStructureManager().getOrCreate(new ResourceLocation(TransportMod.MOD_ID, name)); if (template != null) { template.placeInWorld(_serverworld, new BlockPos((int) x, (int) y, (int) z), new BlockPos((int) x, (int) y, (int) z), new StructurePlaceSettings().setRotation(Rotation.NONE).setMirror(Mirror.NONE).setIgnoreEntities(true), _serverworld.random, 3); } } How make the structure visible right after placing? Or am I doing something wrong? Thanks in advance!
    • Hey im trying to make server side mod with some basic server commands currently im stuck getting text colored after loading it from a txt file i got the text show up fine but how would i go about getting it recognize color codes like §b or \u00A7b
    • do you mean going to java 7 or java 8 update 320?
    • Downgrade Java one version.
    • I downloaded the server files for a 1.16.5 forge server server (forge-1.16.5-36.2.20) but when i run the .jar file it doesn't start up.   I also tried running it with the following .bat script : "C:\Program Files\Java\jre1.8.0_321\bin\javaw.exe" -Xmx4096M -Xms4096M -jar forgeserver.jar pause when I run the server it gives this log: [25jan2022 14:41:46.874] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher running: args [--gameDir, ., --launchTarget, fmlserver, --fml.forgeVersion, 36.2.20, --fml.mcpVersion, 20210115.111550, --fml.mcVersion, 1.16.5, --fml.forgeGroup, net.minecraftforge] [25jan2022 14:41:46.876] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher 8.0.9+86+master.3cf110c starting: java version 1.8.0_321 by Oracle Corporation [25jan2022 14:41:47.215] [main/INFO] [net.minecraftforge.fml.loading.FixSSL/CORE]: Added Lets Encrypt root certificates as additional trust [25jan2022 14:41:47.248] [main/INFO] [mixin/]: SpongePowered MIXIN Subsystem Version=0.8.4 Source=file:/C:/Users/USER/Desktop/folder%20folder/servers/servers/lege%20folder/libraries/org/spongepowered/mixin/0.8.4/mixin-0.8.4.jar Service=ModLauncher Env=SERVER [25jan2022 14:41:48.005] [main/INFO] [cpw.mods.modlauncher.LaunchServiceHandler/MODLAUNCHER]: Launching target 'fmlserver' with arguments [--gameDir, .] [25jan2022 14:41:48.063] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]: java.lang.NoSuchMethodError: sun.security.util.ManifestEntryVerifier.<init>(Ljava/util/jar/Manifest;)V [25jan2022 14:41:48.064] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:     at cpw.mods.modlauncher.SecureJarHandler.createCodeSource(SecureJarHandler.java:66) [25jan2022 14:41:48.064] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:     at cpw.mods.modlauncher.TransformingClassLoader$DelegatedClassLoader.findClass(TransformingClassLoader.java:275) [25jan2022 14:41:48.065] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:     at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:136) [25jan2022 14:41:48.065] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:     at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:98) [25jan2022 14:41:48.065] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:     at java.lang.ClassLoader.loadClass(Unknown Source) [25jan2022 14:41:48.066] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:     at java.lang.Class.forName0(Native Method) [25jan2022 14:41:48.066] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:     at java.lang.Class.forName(Unknown Source) [25jan2022 14:41:48.066] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:     at net.minecraftforge.fml.loading.FMLServerLaunchProvider.lambda$launchService$0(FMLServerLaunchProvider.java:51) [25jan2022 14:41:48.067] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:     at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [25jan2022 14:41:48.067] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [25jan2022 14:41:48.067] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [25jan2022 14:41:48.068] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:     at cpw.mods.modlauncher.Launcher.run(Launcher.java:82) [25jan2022 14:41:48.068] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:     at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) [25jan2022 14:41:48.068] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:     at net.minecraftforge.server.ServerMain$Runner.runLauncher(ServerMain.java:63) [25jan2022 14:41:48.068] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:     at net.minecraftforge.server.ServerMain$Runner.access$100(ServerMain.java:60) [25jan2022 14:41:48.069] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:     at net.minecraftforge.server.ServerMain.main(ServerMain.java:57)    
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.