Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package crystek.modules;
- import crystek.Crystek;
- import crystek.modules.materials.MaterialsModule;
- import net.minecraftforge.fml.common.Loader;
- import net.minecraftforge.fml.common.event.FMLInitializationEvent;
- import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
- import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
- import java.util.ArrayList;
- import java.util.List;
- /**
- * @author Prospector on 28/05/16
- */
- public class ModuleRegistry
- {
- public static MaterialsModule materialsModule = new MaterialsModule();
- public static List<Module> modules = new ArrayList<Module>();
- public static List<String> moduleIds = new ArrayList<String>();
- public static void addModules()
- {
- modules.add(materialsModule);
- for(Module i : modules)
- moduleIds.add(i.getModuleID());
- }
- public static void preInit(FMLPreInitializationEvent event)
- {
- addModules();
- for (Module i : modules)
- {
- if (hasRequirements(i))
- {
- Crystek.logHelper.info("Module " + i.getModuleID() + " is being PreInitialized");
- i.preInit(event);
- }
- }
- }
- public static void init(FMLInitializationEvent event)
- {
- for (Module i : modules)
- {
- if (hasRequirements(i))
- {
- Crystek.logHelper.info("Module " + i.getModuleID() + " is being Initialized");
- i.init(event);
- }
- }
- }
- public static void postInit(FMLPostInitializationEvent event)
- {
- for (Module i : modules)
- {
- if (hasRequirements(i))
- {
- Crystek.logHelper.info("Module " + i.getModuleID() + " is being PostInitialized");
- i.postInit(event);
- }
- }
- }
- public static boolean hasRequirements(Module module)
- {
- String[] reqMods = module.getModsRequired();
- String[] reqModules = module.getModsRequired();
- if (reqMods != null)
- for (String i : reqMods)
- {
- if (!Loader.isModLoaded(i))
- {
- return false;
- }
- }
- if (reqModules != null)
- for (String i : reqModules)
- {
- if (!moduleIds.contains(i))
- {
- return false;
- }
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement