2017-09-06 21:14:50 +00:00
|
|
|
package net.minecraftforge.debug;
|
|
|
|
|
|
|
|
import net.minecraft.client.gui.FontRenderer;
|
|
|
|
import net.minecraft.client.gui.GuiErrorScreen;
|
2018-01-23 07:03:17 +00:00
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraftforge.common.MinecraftForge;
|
|
|
|
import net.minecraftforge.event.RegistryEvent;
|
2017-09-06 21:14:50 +00:00
|
|
|
import net.minecraftforge.fml.client.CustomModLoadingErrorDisplayException;
|
|
|
|
import net.minecraftforge.fml.common.Mod;
|
|
|
|
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
2018-01-16 05:17:00 +00:00
|
|
|
import net.minecraftforge.fml.common.event.FMLLoadCompleteEvent;
|
2017-09-06 21:14:50 +00:00
|
|
|
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
2018-01-23 07:03:17 +00:00
|
|
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
2017-09-06 21:14:50 +00:00
|
|
|
|
|
|
|
@Mod(modid = "clientexceptiontest", version = "1.0", name = "Client Exception Test", clientSideOnly = true)
|
|
|
|
public class ClientExceptionTestMod
|
|
|
|
{
|
|
|
|
|
|
|
|
// Disabled so other test mods can still work.
|
2018-01-16 05:17:00 +00:00
|
|
|
public static boolean ENABLE_PREINIT = false;
|
|
|
|
public static boolean ENABLE_INIT = false;
|
|
|
|
public static boolean ENABLE_LOAD_COMPLETE = false;
|
2017-09-06 21:14:50 +00:00
|
|
|
|
|
|
|
@Mod.EventHandler
|
|
|
|
public void onPreInit(FMLPreInitializationEvent e)
|
|
|
|
{
|
|
|
|
if (ENABLE_PREINIT)
|
|
|
|
{
|
2018-01-23 07:03:17 +00:00
|
|
|
MinecraftForge.EVENT_BUS.register(this);
|
2017-09-06 21:14:50 +00:00
|
|
|
throwException("Thrown in Pre-Init");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-23 07:03:17 +00:00
|
|
|
@SubscribeEvent
|
|
|
|
public void registerItems(RegistryEvent<Item> itemRegistryEvent)
|
|
|
|
{
|
|
|
|
throw new RuntimeException("This should not be called because the mod threw an exception earlier in Pre-Init and is in a broken state.");
|
|
|
|
}
|
|
|
|
|
2017-09-06 21:14:50 +00:00
|
|
|
@Mod.EventHandler
|
|
|
|
public void onInit(FMLInitializationEvent e)
|
|
|
|
{
|
|
|
|
if (ENABLE_INIT)
|
|
|
|
{
|
|
|
|
throwException("Thrown in Init");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-16 05:17:00 +00:00
|
|
|
@Mod.EventHandler
|
|
|
|
public void onLoadComplete(FMLLoadCompleteEvent e)
|
|
|
|
{
|
|
|
|
if (ENABLE_LOAD_COMPLETE)
|
|
|
|
{
|
|
|
|
throwException("Thrown in load complete");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-06 21:14:50 +00:00
|
|
|
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);
|
2018-01-16 05:17:00 +00:00
|
|
|
parent.drawCenteredString(parent.mc.fontRenderer, runtimeMessage, parent.width / 2, 110, 16777215);
|
2017-09-06 21:14:50 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|