kamokuma Posted August 9, 2014 Posted August 9, 2014 I am trying to use loadWorld() method from net.minecraft.client.Minecraft. However it keeps crashing the game. I see the message "RAWR" and then the NullPointer exception is thrown. Am I using this method correctly? How do I get this method to not crash. I am on verison: 1.7.10-10.13.0.1191. Usage: private Minecraft mc; mc.theWorld.sendQuittingDisconnectingPacket(); mc.loadWorld((WorldClient) null, "RAWR"); while (mc.isIntegratedServerRunning()) try{ Thread.sleep(20); }catch (InterruptedException e){} Error: [14:41:12] [server thread/INFO]: Stopping server [14:41:12] [server thread/INFO]: Saving players [14:41:12] [server thread/INFO]: Saving worlds [14:41:12] [server thread/INFO]: Saving chunks for level 'New World'/Overworld [14:41:12] [server thread/INFO]: Saving chunks for level 'New World'/Nether [14:41:12] [server thread/INFO]: Saving chunks for level 'New World'/The End [14:41:13] [server thread/INFO] [FML]: Unloading dimension 0 [14:41:13] [server thread/INFO] [FML]: Unloading dimension -1 [14:41:13] [server thread/INFO] [FML]: Unloading dimension 1 [14:41:13] [server thread/INFO] [FML]: Applying holder lookups [14:41:13] [server thread/INFO] [FML]: Holder lookups applied [14:41:14] [Client thread/FATAL]: Unreported exception thrown! java.lang.NullPointerException at net.minecraft.client.Minecraft.runTick(Minecraft.java:2004) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1038) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:961) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_11] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_11] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_11] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_11] at net.minecraft.launchwrapper.Launch.launch(Launch.java:134) [launchwrapper-1.9.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.9.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_11] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_11] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_11] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_11] at GradleStart.bounce(GradleStart.java:108) [start/:?] at GradleStart.startClient(GradleStart.java:101) [start/:?] at GradleStart.main(GradleStart.java:66) [start/:?]
TheGreyGhost Posted August 10, 2014 Posted August 10, 2014 Hi What are you trying to do actually? Trying to load a null world is definitely going to end in tears. -TGG
kamokuma Posted August 10, 2014 Author Posted August 10, 2014 I want to unload the current world and start another. The loadWorld() method's javadocs says it will unloads the world first. Is there a better way to implement this?
TheGreyGhost Posted August 10, 2014 Posted August 10, 2014 Hi Your (WorldClient)null is for sure not right. I imagine you need to construct a valid new WorldClient first before you call loadWorld(). To be honest I've never tried this so I've never looked into the details, but I suggest you look at the vanilla to see how it uses the loadWorld() method. You will also need to trigger it on both the server and the client, which needs some careful thought. Are you wanting to quit the current world and load a new one? Or just to add another parallel dimension similar to the nether? -TGG
kamokuma Posted August 11, 2014 Author Posted August 11, 2014 I want to quit the current world and load another world that is already saved.
kirstym Posted June 1, 2021 Posted June 1, 2021 This was the only thread I could find when I was seeking out how to quit the current world and load another world that is already saved, so I thought I'd post a solution for anyone in the future who might have the same goal... the following is for Forge 1.14.4 and can be called during an `onKeyInput` callback. It works for a local world (i.e. using an integrated server). // Disconnect from current world Minecraft.getInstance().world.sendQuittingDisconnectingPacket(); Minecraft.getInstance().func_213231_b(new DirtMessageScreen(new StringTextComponent("Reloading"))); // Connect to another with folder name "New World" and world name "New World" String folderName = "New World"; String worldName = "New World"; WorldSettings settings = null; Minecraft.getInstance().launchIntegratedServer(folderName, worldName, settings);
Recommended Posts