Fix CustomModLoadingErrorDisplayScreen not being handled during init or preinit. (#4320)

This commit is contained in:
Benjamin K authored and LexManos committed 2017-09-06 14:14:50 -07:00
1 parent dadc715e7d
commit 45c2ff5329
3 files changed
+78 -22

No files matched your search

@@ -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<String,Map<String,String>> sharedModList = (Map<String, Map<String, String>>) 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();
}
@@ -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);
}
}
@@ -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);
}
};
}
}