From 06856eb95751c1ba5feac767980a234c061b6496 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sat, 2 Aug 2014 23:34:49 -0500 Subject: [PATCH] Added Core Mod Error. --- core/AppEng.java | 8 ++++- transformer/MissingCoreMod.java | 63 +++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 transformer/MissingCoreMod.java diff --git a/core/AppEng.java b/core/AppEng.java index f4c41b6a..c05bed1a 100644 --- a/core/AppEng.java +++ b/core/AppEng.java @@ -22,11 +22,13 @@ import appeng.integration.IntegrationType; import appeng.server.AECommand; import appeng.services.Profiler; import appeng.services.VersionChecker; +import appeng.transformer.MissingCoreMod; import appeng.util.Platform; import com.google.common.base.Stopwatch; import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.event.FMLInitializationEvent; @@ -64,7 +66,8 @@ public class AppEng // "after:gregtech_addon;after:Mekanism;after:IC2;after:ThermalExpansion;after:BuildCraft|Core;" + // depend on version of forge used for build. - "required-after:appliedenergistics2-core;" + "required-after:Forge@[" // require forge. + // "required-after:appliedenergistics2-core;" + + "required-after:Forge@[" // require forge. + net.minecraftforge.common.ForgeVersion.majorVersion + "." // majorVersion + net.minecraftforge.common.ForgeVersion.minorVersion + "." // minorVersion + net.minecraftforge.common.ForgeVersion.revisionVersion + "." // revisionVersion @@ -106,6 +109,9 @@ public class AppEng @EventHandler void PreInit(FMLPreInitializationEvent event) { + if ( !Loader.isModLoaded( "after:appliedenergistics2-core" ) ) + throw new MissingCoreMod(); + Stopwatch star = Stopwatch.createStarted(); configPath = event.getModConfigurationDirectory().getPath() + File.separator + "AppliedEnergistics2" + File.separator; diff --git a/transformer/MissingCoreMod.java b/transformer/MissingCoreMod.java new file mode 100644 index 00000000..9ee4d19e --- /dev/null +++ b/transformer/MissingCoreMod.java @@ -0,0 +1,63 @@ +package appeng.transformer; + +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.GuiErrorScreen; +import cpw.mods.fml.client.CustomModLoadingErrorDisplayException; + +public class MissingCoreMod extends CustomModLoadingErrorDisplayException +{ + + private static final long serialVersionUID = -966774766922821652L; + private boolean deobf = false; + + @Override + public void initGui(GuiErrorScreen errorScreen, FontRenderer fontRenderer) + { + Class clz = errorScreen.getClass(); + try + { + clz.getField( "mc" ); + deobf = true; + } + catch (Throwable e) + { + + } + } + + @Override + public void drawScreen(GuiErrorScreen errorScreen, FontRenderer fontRenderer, int mouseRelX, int mouseRelY, float tickTime) + { + int offset = 10; + drawCenteredString( fontRenderer, "Sorry, couldn't load AE2 Properly.", errorScreen.width / 2, offset += 15, 0xffffff ); + drawCenteredString( fontRenderer, "Please make sure that AE2 is installed into your mods folder.", errorScreen.width / 2, offset += 15, 0xeeeeee ); + + offset += 15; + + if ( deobf ) + { + offset += 15; + drawCenteredString( fontRenderer, "In a developer environment add the following too your args,", errorScreen.width / 2, offset += 15, 0xffffff ); + drawCenteredString( fontRenderer, "-Dfml.coreMods.load=appeng.transformer.AppEngCore", errorScreen.width / 2, offset += 15, 0xeeeeee ); + } + else + { + drawCenteredString( fontRenderer, "You're launcher may refer to this by diffrent names,", errorScreen.width / 2, offset += 15, 0xffffff ); + + offset += 5; + + drawCenteredString( fontRenderer, "MultiMC calls this tab \"Loader Mods\"", errorScreen.width / 2, offset += 15, 0xeeeeee ); + drawCenteredString( fontRenderer, "Magic Launcher calls this tab \"External Mods\"", errorScreen.width / 2, offset += 15, 0xeeeeee ); + drawCenteredString( fontRenderer, "Most other launchers refer to this tab as just \"Mods\"", errorScreen.width / 2, offset += 15, 0xeeeeee ); + + offset += 15; + + drawCenteredString( fontRenderer, "Also make sure that the AE2 file is a .jar, and not a .zip", errorScreen.width / 2, offset += 15, 0xffffff ); + } + } + + public void drawCenteredString(FontRenderer fontRenderer, String string, int x, int y, int colour) + { + fontRenderer.drawStringWithShadow( string, x - fontRenderer.getStringWidth( string.replaceAll( "\\P{InBasic_Latin}", "" ) ) / 2, y, colour ); + } +} \ No newline at end of file