TechReborn/src/main/java/techreborn/compat/CompatManager.java

100 lines
3.7 KiB
Java
Raw Normal View History

package techreborn.compat;
2016-03-04 20:47:08 +01:00
import net.minecraftforge.fml.common.FMLCommonHandler;
2015-11-23 15:40:30 +01:00
import net.minecraftforge.fml.common.Loader;
2016-03-04 20:47:08 +01:00
import net.minecraftforge.fml.relauncher.Side;
import techreborn.client.render.parts.ClientPartLoader;
2016-03-21 17:56:20 +01:00
import techreborn.compat.waila.CompatModuleWaila;
import techreborn.config.ConfigTechReborn;
2016-03-06 15:51:13 +01:00
import techreborn.parts.StandalonePartCompact;
2016-03-19 19:01:34 +01:00
import techreborn.parts.TechRebornParts;
2016-03-21 20:45:48 +01:00
import techreborn.parts.walia.WailaMcMultiPartCompact;
2015-06-12 19:40:08 +02:00
import java.util.ArrayList;
public class CompatManager {
public ArrayList<ICompatModule> compatModules = new ArrayList<ICompatModule>();
2015-06-12 19:40:08 +02:00
public static CompatManager INSTANCE = new CompatManager();
2015-06-12 19:40:08 +02:00
2015-10-14 14:39:05 +02:00
public static boolean isIC2Loaded = false;
public static boolean isIC2ClassicLoaded = false;
2015-11-11 18:08:41 +01:00
public static boolean isClassicEnet = false;
2015-12-05 23:48:11 +01:00
public static boolean isGregTechLoaded = false;
2015-06-12 19:40:08 +02:00
public CompatManager() {
2015-10-14 14:39:05 +02:00
isIC2Loaded = Loader.isModLoaded("IC2");
2015-11-29 11:42:34 +01:00
isIC2ClassicLoaded = false;
2015-12-05 23:48:11 +01:00
if (isIC2ClassicLoaded) {
2015-11-11 18:08:41 +01:00
isClassicEnet = true;
}
2015-12-05 23:48:11 +01:00
if (Loader.isModLoaded("Uncomplication")) {
2015-11-11 18:08:41 +01:00
isClassicEnet = true;
}
2015-12-05 23:48:11 +01:00
if (Loader.isModLoaded("gregtech")) {
2015-11-22 12:16:54 +01:00
isGregTechLoaded = true;
2015-11-22 11:27:33 +01:00
}
2016-03-21 17:56:20 +01:00
registerCompact(CompatModuleWaila.class, "Waila");
2016-03-13 17:08:30 +01:00
// registerCompact(MinetweakerCompat.class, "MineTweaker3");
// registerCompact(RecipesBiomesOPlenty.class, "BiomesOPlenty");
// registerCompact(RecipesBuildcraft.class, "BuildCraft|Builders");
// registerCompact(RecipesThaumcraft.class, "Thaumcraft");
2016-03-19 19:01:34 +01:00
registerCompact(TechRebornParts.class, "mcmultipart");
registerCompact(ClientPartLoader.class, "mcmultipart", "@client");
2016-03-06 15:51:13 +01:00
registerCompact(StandalonePartCompact.class, "!mcmultipart");
2016-03-21 20:45:48 +01:00
registerCompact(WailaMcMultiPartCompact.class, "mcmultipart", "Waila");
}
public void registerCompact(Class<? extends ICompatModule> moduleClass, Object... objs) {
boolean shouldLoad = ConfigTechReborn.config.get(ConfigTechReborn.CATEGORY_INTEGRATION, "Compat:" + moduleClass.getSimpleName(), true, "Should the " + moduleClass.getSimpleName() + " be loaded?").getBoolean(true);
if (ConfigTechReborn.config.hasChanged())
ConfigTechReborn.config.save();
if(!shouldLoad){
return;
}
2015-11-08 13:15:45 +01:00
for (Object obj : objs) {
if (obj instanceof String) {
2015-08-30 22:16:22 +02:00
String modid = (String) obj;
2016-03-04 20:47:08 +01:00
if(modid.startsWith("@")){
if(modid.equals("@client")){
if(FMLCommonHandler.instance().getSide() != Side.CLIENT){
return;
}
}
} else if (modid.startsWith("!")) {
if (Loader.isModLoaded(modid.replaceAll("!", ""))) {
2015-08-30 22:16:22 +02:00
return;
}
} else {
if (!Loader.isModLoaded(modid)) {
return;
}
}
2015-11-08 13:15:45 +01:00
} else if (obj instanceof Boolean) {
Boolean boo = (Boolean) obj;
2015-11-08 13:15:45 +01:00
if (boo == false) {
2015-08-30 22:16:22 +02:00
}
2015-11-08 13:15:45 +01:00
return;
}
}
try {
compatModules.add((ICompatModule) moduleClass.newInstance());
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
2015-10-07 09:34:24 +02:00
2015-11-08 13:15:45 +01:00
public boolean isForestry4() {
2015-10-07 09:34:24 +02:00
try {
Class.forName("forestry.api.arboriculture.EnumWoodType");
return true;
2015-11-08 13:15:45 +01:00
} catch (ClassNotFoundException e) {
2015-10-07 09:34:24 +02:00
return false;
}
}
2015-11-11 18:08:41 +01:00
}