Applied-Energistics-2-tiler.../core/AppEng.java

198 lines
6.5 KiB
Java
Raw Normal View History

package appeng.core;
2014-02-11 06:50:05 +01:00
import java.io.File;
import java.util.concurrent.TimeUnit;
2014-02-11 06:50:05 +01:00
import appeng.core.crash.CrashEnhancement;
import appeng.core.crash.CrashInfo;
import appeng.core.features.AEFeature;
2014-02-09 02:34:52 +01:00
import appeng.core.sync.GuiBridge;
import appeng.core.sync.network.NetworkHandler;
import appeng.hooks.TickHandler;
import appeng.integration.IntegrationRegistry;
import appeng.integration.IntegrationSide;
import appeng.server.AECommand;
import appeng.services.Profiler;
import appeng.services.VersionChecker;
import appeng.util.Platform;
import com.google.common.base.Stopwatch;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerAboutToStartEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.event.FMLServerStoppingEvent;
2014-02-09 02:34:52 +01:00
import cpw.mods.fml.common.network.NetworkRegistry;
2014-02-09 06:08:27 +01:00
@Mod(modid = AppEng.modid, name = AppEng.name, version = AEConfig.VERSION, dependencies = AppEng.dependencies)
public class AppEng
{
2014-02-11 06:50:05 +01:00
private String configPath;
public String getConfigPath()
{
return configPath;
}
public final static String modid = "appliedenergistics2";
public final static String name = "Applied Energistics 2";
public static AppEng instance;
public final static String dependencies =
// a few mods, AE should load after, probably.
// required-after:AppliedEnergistics2API|all;
"after:gregtech_addon;after:Mekanism;after:IC2;after:ThermalExpansion;after:BuildCraft|Core;" +
// depend on version of forge used for build.
"required-after:Forge@[" // require forge.
+ net.minecraftforge.common.ForgeVersion.majorVersion + "." // majorVersion
+ net.minecraftforge.common.ForgeVersion.minorVersion + "." // minorVersion
+ net.minecraftforge.common.ForgeVersion.revisionVersion + "." // revisionVersion
+ net.minecraftforge.common.ForgeVersion.buildVersion + ",)"; // buildVersion
public AppEng() {
instance = this;
for (CrashInfo ci : CrashInfo.values())
FMLCommonHandler.instance().registerCrashCallable( new CrashEnhancement( ci ) );
}
private IntegrationRegistry integrationModules = new IntegrationRegistry( new Object[] {
/**
2014-02-20 00:33:36 +01:00
* Side, Display Name, ModID ClassPostFix
*/
2014-02-20 04:16:41 +01:00
IntegrationSide.BOTH, "Industrial Craft 2", "IC2", "IC2", // IC2
// IntegrationSide.BOTH, "Railcraft", "Railcraft", "RC", // RC
// IntegrationSide.BOTH, "Thermal Expansion", "ThermalExpansion", "TE", // TE
// IntegrationSide.BOTH, "Mystcraft", "Mystcraft", "Mystcraft", // MC
IntegrationSide.BOTH, "BuildCraft", "BuildCraft|Silicon", "BC", // BC
IntegrationSide.BOTH, "BuildCraft Power", null, "MJ", // BC
// IntegrationSide.BOTH, "Greg Tech", "gregtech_addon", "GT", // GT
// IntegrationSide.BOTH, "Universal Electricity", null, "UE", // UE
// IntegrationSide.BOTH, "Logistics Pipes", "LogisticsPipes|Main", "LP", // LP
// IntegrationSide.CLIENT, "Inventory Tweaks", "", "InvTweaks", // InvTweaks
// IntegrationSide.BOTH, "Mine Factory Reloaded", "MineFactoryReloaded", "MFR", // MFR
IntegrationSide.BOTH, "Deep Storage Unit", null, "DSU", // DSU
// IntegrationSide.BOTH, "Better Storage", "betterstorage", "BS", // BS
IntegrationSide.BOTH, "Factorization", "factorization", "FZ", // FZ
2014-02-20 04:16:41 +01:00
// IntegrationSide.BOTH, "Forestry", "Forestry", "Forestry", // Forestry
// IntegrationSide.BOTH, "Mekanism", "Mekanism", "Mekanism", // MeK
IntegrationSide.CLIENT, "Waila", "Waila", "Waila", // Waila
2014-04-04 06:12:35 +02:00
IntegrationSide.BOTH, "Rotatable Blocks", "RotatableBlocks", "RB", // RB
IntegrationSide.CLIENT, "Inventory Tweaks", "inventorytweaks", "InvTweaks", // INV
IntegrationSide.CLIENT, "Not Enough Items", "NotEnoughItems", "NEI", // NEI
2014-03-24 08:55:46 +01:00
IntegrationSide.CLIENT, "Craft Guide", "craftguide", "CraftGuide", // CraftGuide
2014-02-20 04:16:41 +01:00
IntegrationSide.BOTH, "Forge MultiPart", "McMultipart", "FMP" // FMP
} );
public boolean isIntegrationEnabled(String Name)
{
return integrationModules.isEnabled( Name );
}
public Object getIntegration(String Name)
{
return integrationModules.getInstance( Name );
}
2014-01-01 10:01:58 +01:00
private void startService(String serviceName, Thread thread)
{
thread.setName( serviceName );
thread.setPriority( Thread.MIN_PRIORITY );
thread.start();
}
@EventHandler
void PreInit(FMLPreInitializationEvent event)
{
Stopwatch star = Stopwatch.createStarted();
2014-02-11 06:50:05 +01:00
configPath = event.getModConfigurationDirectory().getPath() + File.separator + "AppliedEnergistics2" + File.separator;
AEConfig.instance = new AEConfig( configPath );
FacadeConfig.instance = new FacadeConfig( configPath );
2014-02-07 21:56:50 +01:00
AELog.info( "Starting ( PreInit )" );
if ( Platform.isClient() )
{
CreativeTab.init();
2014-02-01 23:24:13 +01:00
CreativeTabFacade.init();
CommonHelper.proxy.init();
}
Registration.instance.PreInit( event );
2014-02-09 06:08:27 +01:00
if ( AEConfig.instance.isFeatureEnabled( AEFeature.Profiler ) )
{
AELog.info( "Starting Profiler" );
2014-01-01 10:01:58 +01:00
startService( "AE2 Profiler", (new Thread( Profiler.instance = new Profiler() )) );
}
2014-02-09 06:08:27 +01:00
if ( AEConfig.instance.isFeatureEnabled( AEFeature.VersionChecker ) )
{
AELog.info( "Starting VersionChecker" );
2014-01-01 10:01:58 +01:00
startService( "AE2 VersionChecker", new Thread( VersionChecker.instance = new VersionChecker() ) );
}
AELog.info( "PreInit ( end " + star.elapsed( TimeUnit.MILLISECONDS ) + "ms )" );
}
@EventHandler
void Init(FMLInitializationEvent event)
{
Stopwatch star = Stopwatch.createStarted();
AELog.info( "Init" );
Registration.instance.Init( event );
integrationModules.init();
AELog.info( "Init ( end " + star.elapsed( TimeUnit.MILLISECONDS ) + "ms )" );
}
@EventHandler
void PostInit(FMLPostInitializationEvent event)
{
Stopwatch star = Stopwatch.createStarted();
AELog.info( "PostInit" );
Registration.instance.PostInit( event );
integrationModules.postinit();
2014-02-09 06:08:27 +01:00
AEConfig.instance.save();
2014-02-09 02:34:52 +01:00
NetworkRegistry.INSTANCE.registerGuiHandler( this, GuiBridge.GUI_Handler );
NetworkHandler.instance = new NetworkHandler( "AE2" );
AELog.info( "PostInit ( end " + star.elapsed( TimeUnit.MILLISECONDS ) + "ms )" );
}
@EventHandler
public void serverStopping(FMLServerStoppingEvent event)
{
WorldSettings.getInstance().shutdown();
TickHandler.instance.shutdown();
}
@EventHandler
public void serverStarting(FMLServerAboutToStartEvent evt)
{
WorldSettings.getInstance().init();
}
@EventHandler
public void serverStarting(FMLServerStartingEvent evt)
{
evt.registerServerCommand( new AECommand( evt.getServer() ) );
}
}