Vectron / mapwriter

MapWriter: A minimap mod for Minecraft
MIT License
56 stars 38 forks source link

java.lang.NullPointerException at mapwriter.util.Utils.getWorldName(Utils.java:159) with Replay Mod #59

Open TheSnoozer opened 7 years ago

TheSnoozer commented 7 years ago

Hi I'm using Minecraft 1.8 with the following mods

When watching my replayfiles (basically a recording of what happend) I get the following


java.lang.NullPointerException
    at mapwriter.util.Utils.getWorldName(Utils.java:159) ~[Utils.class:?]
    at mapwriter.Mw.load(Mw.java:354) ~[Mw.class:?]
    at mapwriter.Mw.onTick(Mw.java:457) ~[Mw.class:?]
    at mapwriter.forge.EventHandler.renderMap(EventHandler.java:105) ~[EventHandler.class:?]
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_55_EventHandler_renderMap_Post.invoke(.dynamic) ~[?:?]
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:55) ~[ASMEventHandler.class:?]
    at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:140) [EventBus.class:?]
    at net.minecraftforge.client.GuiIngameForge.post(GuiIngameForge.java:858) [GuiIngameForge.class:?]
    at net.minecraftforge.client.GuiIngameForge.func_175180_a(GuiIngameForge.java:190) [GuiIngameForge.class:?]
    at net.minecraft.client.renderer.EntityRenderer.func_78480_b(EntityRenderer.java:1381) [cji.class:?]
    at net.minecraft.client.Minecraft.func_71411_J(Minecraft.java:1055) [bsu.class:?]
    at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:345) [bsu.class:?]
    at net.minecraft.client.main.Main.main(SourceFile:120) [Main.class:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_131]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_131]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_131]
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?]
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?]```

A valid fix seems to verify if the serverIp is not null:
``net.minecraft.client.multiplayer.ServerData serverData = Minecraft.getMinecraft().getCurrentServerData();
if(serverData != null){
    worldName = serverData.serverIP;
    // ....
} else {
    worldName = "default";
}``
Vectron commented 7 years ago

will fix this