2013-10-22 20:09:21 +01:00
|
|
|
package tconstruct.util;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
2013-12-06 16:18:07 +00:00
|
|
|
import mantle.crash.CallableSuppConfig;
|
|
|
|
|
import mantle.crash.CallableUnsuppConfig;
|
2013-12-19 08:16:57 -08:00
|
|
|
import net.minecraft.client.gui.GuiMainMenu;
|
|
|
|
|
import net.minecraftforge.client.event.GuiOpenEvent;
|
|
|
|
|
import net.minecraftforge.common.MinecraftForge;
|
|
|
|
|
import net.minecraftforge.event.ForgeSubscribe;
|
|
|
|
|
import tconstruct.TConstruct;
|
|
|
|
|
import cpw.mods.fml.common.FMLCommonHandler;
|
|
|
|
|
import cpw.mods.fml.common.ICrashCallable;
|
|
|
|
|
import cpw.mods.fml.common.Loader;
|
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2013-12-05 00:29:59 -05:00
|
|
|
|
2013-11-10 13:57:35 -08:00
|
|
|
public class EnvironmentChecks
|
|
|
|
|
{
|
2013-10-22 20:09:21 +01:00
|
|
|
|
2013-11-10 13:57:35 -08:00
|
|
|
private EnvironmentChecks()
|
|
|
|
|
{
|
|
|
|
|
} // Singleton
|
2013-10-22 20:09:21 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Checks for conflicting stuff in environment; adds callable to any crash logs if so.
|
2013-11-23 09:31:19 -05:00
|
|
|
* Note: This code adds additional data to crashlogs. It does not trigger any crashes.
|
2013-10-22 20:09:21 +01:00
|
|
|
*/
|
2013-12-19 08:16:57 -08:00
|
|
|
private static List<String> incompatibilities = new ArrayList<String>();
|
|
|
|
|
private static EnvironmentChecks instance = new EnvironmentChecks();
|
|
|
|
|
|
2013-11-10 13:57:35 -08:00
|
|
|
public static void verifyEnvironmentSanity ()
|
|
|
|
|
{
|
2013-10-30 22:15:03 +00:00
|
|
|
List<String> modIds = new ArrayList<String>();
|
2013-10-24 12:27:50 +01:00
|
|
|
|
2013-12-19 08:31:06 -08:00
|
|
|
if (Loader.isModLoaded("gregtech_addon"))
|
2013-11-10 13:57:35 -08:00
|
|
|
{
|
2013-12-19 08:16:57 -08:00
|
|
|
TConstruct.logger.severe("Tinkers' Construct and GregTech are incompatible for the following reasons:");
|
|
|
|
|
TConstruct.logger.severe(modCompatDetails("GregTech", true));
|
2013-10-22 20:09:21 +01:00
|
|
|
modIds.add("gregtech_addon");
|
2013-12-19 08:16:57 -08:00
|
|
|
incompatibilities.add("GregTech");
|
2013-10-30 22:15:03 +00:00
|
|
|
}
|
2013-10-22 20:09:21 +01:00
|
|
|
|
2013-12-06 16:57:33 +00:00
|
|
|
// Bukkit/Magic Launcher/Optifine are caught by Mantle, so we no longer check for those.
|
2013-11-30 19:50:18 +00:00
|
|
|
|
2013-11-10 13:57:35 -08:00
|
|
|
if (modIds.size() == 0)
|
|
|
|
|
{
|
2013-12-06 16:18:07 +00:00
|
|
|
ICrashCallable callable = new CallableSuppConfig("TConstruct");
|
2013-10-24 12:27:50 +01:00
|
|
|
FMLCommonHandler.instance().registerCrashCallable(callable);
|
2013-11-10 13:57:35 -08:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-12-06 16:18:07 +00:00
|
|
|
ICrashCallable callable = new CallableUnsuppConfig("TConstruct", modIds);
|
2013-10-30 22:15:03 +00:00
|
|
|
FMLCommonHandler.instance().registerCrashCallable(callable);
|
2013-10-22 20:09:21 +01:00
|
|
|
}
|
2013-12-19 08:16:57 -08:00
|
|
|
|
|
|
|
|
if (incompatibilities.size() > 0 && FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT)
|
|
|
|
|
{
|
|
|
|
|
MinecraftForge.EVENT_BUS.register(instance);
|
|
|
|
|
}
|
2013-10-22 20:09:21 +01:00
|
|
|
}
|
|
|
|
|
|
2013-12-19 08:16:57 -08:00
|
|
|
public static String modCompatDetails (String type, boolean consoleFormat)
|
|
|
|
|
{
|
|
|
|
|
String n = consoleFormat ? System.getProperty("line.separator") : "\n";
|
|
|
|
|
if (type.equals("GregTech"))
|
|
|
|
|
{
|
2013-12-19 11:37:04 -08:00
|
|
|
return "- GregTech is a meta-mod that changes how a lot of mods interact with the base game and with each other." + n
|
2013-12-19 11:53:53 -08:00
|
|
|
+ "- The mod makes broad assumptions and changes to how the ore dictionary works";
|
2013-12-19 08:16:57 -08:00
|
|
|
}
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
|
@ForgeSubscribe
|
|
|
|
|
public void openMainMenu (GuiOpenEvent event)
|
|
|
|
|
{
|
|
|
|
|
if (event.gui instanceof GuiMainMenu)
|
|
|
|
|
{
|
|
|
|
|
if (incompatibilities.size() > 0)
|
|
|
|
|
{
|
|
|
|
|
event.gui = new EnvironmentGui(event.gui, incompatibilities);
|
|
|
|
|
}
|
|
|
|
|
MinecraftForge.EVENT_BUS.unregister(instance);
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-10-22 20:09:21 +01:00
|
|
|
}
|