diff --git a/src/main/java/net/minecraftforge/fml/client/FMLClientHandler.java b/src/main/java/net/minecraftforge/fml/client/FMLClientHandler.java index b3900cb924..6f7c1dc388 100644 --- a/src/main/java/net/minecraftforge/fml/client/FMLClientHandler.java +++ b/src/main/java/net/minecraftforge/fml/client/FMLClientHandler.java @@ -265,16 +265,21 @@ public class FMLClientHandler implements IFMLSidedHandler { Loader.instance().preinitializeMods(); } - catch (CustomModLoadingErrorDisplayException custom) - { - FMLLog.log.error("A custom exception was thrown by a mod, the game will now halt", custom); - customError = custom; - } catch (LoaderException le) { - haltGame("There was a severe problem during mod loading that has caused the game to fail", le); - return; + if (le.getCause() instanceof CustomModLoadingErrorDisplayException) + { + CustomModLoadingErrorDisplayException custom = (CustomModLoadingErrorDisplayException) le.getCause(); + FMLLog.log.error("A custom exception was thrown by a mod, the game will now halt", custom); + customError = custom; + } + else + { + haltGame("There was a severe problem during mod loading that has caused the game to fail", le); + return; + } } + Map> sharedModList = (Map>) Launch.blackboard.get("modList"); if (sharedModList == null) { @@ -342,17 +347,19 @@ public class FMLClientHandler implements IFMLSidedHandler { Loader.instance().initializeMods(); } - catch (CustomModLoadingErrorDisplayException custom) - { - FMLLog.log.error("A custom exception was thrown by a mod, the game will now halt", custom); - customError = custom; - SplashProgress.finish(); - return; - } catch (LoaderException le) { - haltGame("There was a severe problem during mod loading that has caused the game to fail", le); - return; + if (le.getCause() instanceof CustomModLoadingErrorDisplayException) + { + CustomModLoadingErrorDisplayException custom = (CustomModLoadingErrorDisplayException) le.getCause(); + FMLLog.log.error("A custom exception was thrown by a mod, the game will now halt", custom); + customError = custom; + } + else + { + haltGame("There was a severe problem during mod loading that has caused the game to fail", le); + return; + } } // This call is being phased out for performance reasons in 1.12, @@ -390,7 +397,8 @@ public class FMLClientHandler implements IFMLSidedHandler } loading = false; client.gameSettings.loadOptions(); //Reload options to load any mod added keybindings. - Loader.instance().loadingComplete(); + if (customError == null) + Loader.instance().loadingComplete(); SplashProgress.finish(); } diff --git a/src/main/java/net/minecraftforge/fml/client/GuiCustomModLoadingErrorScreen.java b/src/main/java/net/minecraftforge/fml/client/GuiCustomModLoadingErrorScreen.java index 10fa883b17..bfa5b6590e 100644 --- a/src/main/java/net/minecraftforge/fml/client/GuiCustomModLoadingErrorScreen.java +++ b/src/main/java/net/minecraftforge/fml/client/GuiCustomModLoadingErrorScreen.java @@ -19,27 +19,24 @@ package net.minecraftforge.fml.client; -import net.minecraft.client.gui.GuiErrorScreen; - -public class GuiCustomModLoadingErrorScreen extends GuiErrorScreen +public class GuiCustomModLoadingErrorScreen extends GuiErrorBase { private CustomModLoadingErrorDisplayException customException; public GuiCustomModLoadingErrorScreen(CustomModLoadingErrorDisplayException customException) { - super(null,null); this.customException = customException; } @Override public void initGui() { super.initGui(); - this.buttonList.clear(); this.customException.initGui(this, fontRenderer); } @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { this.drawDefaultBackground(); + super.drawScreen(mouseX, mouseY, partialTicks); this.customException.drawScreen(this, fontRenderer, mouseX, mouseY, partialTicks); } } diff --git a/src/test/java/net/minecraftforge/debug/ClientExceptionTestMod.java b/src/test/java/net/minecraftforge/debug/ClientExceptionTestMod.java new file mode 100644 index 0000000000..b45e2046b8 --- /dev/null +++ b/src/test/java/net/minecraftforge/debug/ClientExceptionTestMod.java @@ -0,0 +1,51 @@ +package net.minecraftforge.debug; + +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.GuiErrorScreen; +import net.minecraftforge.fml.client.CustomModLoadingErrorDisplayException; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; + +@Mod(modid = "clientexceptiontest", version = "1.0", name = "Client Exception Test", clientSideOnly = true) +public class ClientExceptionTestMod +{ + + // Disabled so other test mods can still work. + public static boolean ENABLE_PREINIT = false, ENABLE_INIT = false; + private static String LOREM_IPSUM = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."; + + @Mod.EventHandler + public void onPreInit(FMLPreInitializationEvent e) + { + if (ENABLE_PREINIT) + { + throwException("Thrown in Pre-Init"); + } + } + + @Mod.EventHandler + public void onInit(FMLInitializationEvent e) + { + if (ENABLE_INIT) + { + throwException("Thrown in Init"); + } + } + + private void throwException(String runtimeMessage) + { + throw new CustomModLoadingErrorDisplayException("Custom Test Exception", new RuntimeException(runtimeMessage)) + { + @Override + public void initGui(GuiErrorScreen parent, FontRenderer fontRenderer) {} + + @Override + public void drawScreen(GuiErrorScreen parent, FontRenderer fontRenderer, int mouseRelX, int mouseRelY, float tickTime) + { + parent.drawCenteredString(parent.mc.fontRenderer, "Custom Test Exception", parent.width / 2, 90, 16777215); + parent.drawCenteredString(parent.mc.fontRenderer, LOREM_IPSUM, parent.width / 2, 110, 16777215); + } + }; + } +}