Jump to content

Recommended Posts

Posted

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/:?]

 

Posted

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?

Posted

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

  • 6 years later...
Posted

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

 

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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