2013-12-27 23:59:59 +01:00
|
|
|
package appeng.core;
|
|
|
|
|
2014-02-11 06:50:05 +01:00
|
|
|
import java.io.File;
|
2014-04-18 04:52:39 +02:00
|
|
|
import java.util.HashMap;
|
2014-03-30 00:36:37 +01:00
|
|
|
import java.util.concurrent.TimeUnit;
|
2014-02-11 06:50:05 +01:00
|
|
|
|
2014-04-18 04:52:39 +02:00
|
|
|
import appeng.api.config.TunnelType;
|
|
|
|
import appeng.core.api.IIMCHandler;
|
|
|
|
import appeng.core.api.imc.IMCGrinder;
|
|
|
|
import appeng.core.api.imc.IMCMatterCannon;
|
|
|
|
import appeng.core.api.imc.IMCP2PAttunement;
|
|
|
|
import appeng.core.api.imc.IMCSpatial;
|
2013-12-27 23:59:59 +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;
|
2014-03-02 09:35:11 +01:00
|
|
|
import appeng.hooks.TickHandler;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.integration.IntegrationRegistry;
|
|
|
|
import appeng.server.AECommand;
|
|
|
|
import appeng.services.Profiler;
|
|
|
|
import appeng.services.VersionChecker;
|
|
|
|
import appeng.util.Platform;
|
2014-03-30 00:36:37 +01:00
|
|
|
|
|
|
|
import com.google.common.base.Stopwatch;
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
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;
|
2014-04-18 04:52:39 +02:00
|
|
|
import cpw.mods.fml.common.event.FMLInterModComms;
|
|
|
|
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
|
2013-12-27 23:59:59 +01:00
|
|
|
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
|
|
|
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
2014-03-30 01:23:11 +01:00
|
|
|
import cpw.mods.fml.common.event.FMLServerAboutToStartEvent;
|
2013-12-27 23:59:59 +01:00
|
|
|
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;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-02-09 06:08:27 +01:00
|
|
|
@Mod(modid = AppEng.modid, name = AppEng.name, version = AEConfig.VERSION, dependencies = AppEng.dependencies)
|
2013-12-27 23:59:59 +01:00
|
|
|
public class AppEng
|
|
|
|
{
|
|
|
|
|
2014-02-11 06:50:05 +01:00
|
|
|
private String configPath;
|
|
|
|
|
|
|
|
public String getConfigPath()
|
|
|
|
{
|
|
|
|
return configPath;
|
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
public final static String modid = "appliedenergistics2";
|
|
|
|
public final static String name = "Applied Energistics 2";
|
|
|
|
|
2014-04-18 04:52:39 +02:00
|
|
|
HashMap<String, IIMCHandler> IMCHandlers = new HashMap();
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
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.
|
2014-04-18 04:52:39 +02:00
|
|
|
"required-after:AppliedEnergistics2-Core;" + "required-after:Forge@[" // require forge.
|
2013-12-27 23:59:59 +01:00
|
|
|
+ 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;
|
|
|
|
|
2014-04-18 04:52:39 +02:00
|
|
|
IMCHandlers.put( "whitelist-spatial", new IMCSpatial() );
|
|
|
|
IMCHandlers.put( "add-grindable", new IMCGrinder() );
|
|
|
|
IMCHandlers.put( "add-mattercannon-ammo", new IMCMatterCannon() );
|
|
|
|
|
|
|
|
for (TunnelType type : TunnelType.values())
|
|
|
|
{
|
|
|
|
IMCHandlers.put( "add-p2p-attunement-" + type.name().replace( '_', '-' ).toLowerCase(), new IMCP2PAttunement() );
|
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
for (CrashInfo ci : CrashInfo.values())
|
|
|
|
FMLCommonHandler.instance().registerCrashCallable( new CrashEnhancement( ci ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isIntegrationEnabled(String Name)
|
|
|
|
{
|
2014-04-06 08:55:24 +02:00
|
|
|
return IntegrationRegistry.instance.isEnabled( Name );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public Object getIntegration(String Name)
|
|
|
|
{
|
2014-04-06 08:55:24 +02:00
|
|
|
return IntegrationRegistry.instance.getInstance( Name );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
@EventHandler
|
|
|
|
void PreInit(FMLPreInitializationEvent event)
|
|
|
|
{
|
2014-03-30 00:36:37 +01:00
|
|
|
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 );
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-02-07 21:56:50 +01:00
|
|
|
AELog.info( "Starting ( PreInit )" );
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
if ( Platform.isClient() )
|
|
|
|
{
|
|
|
|
CreativeTab.init();
|
2014-04-04 17:46:05 +02:00
|
|
|
if ( AEConfig.instance.isFeatureEnabled( AEFeature.Facades ) )
|
|
|
|
CreativeTabFacade.init();
|
2013-12-27 23:59:59 +01:00
|
|
|
CommonHelper.proxy.init();
|
|
|
|
}
|
|
|
|
|
|
|
|
Registration.instance.PreInit( event );
|
|
|
|
|
2014-02-09 06:08:27 +01:00
|
|
|
if ( AEConfig.instance.isFeatureEnabled( AEFeature.Profiler ) )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
AELog.info( "Starting Profiler" );
|
2014-01-01 10:01:58 +01:00
|
|
|
startService( "AE2 Profiler", (new Thread( Profiler.instance = new Profiler() )) );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
2014-02-09 06:08:27 +01:00
|
|
|
if ( AEConfig.instance.isFeatureEnabled( AEFeature.VersionChecker ) )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
AELog.info( "Starting VersionChecker" );
|
2014-01-01 10:01:58 +01:00
|
|
|
startService( "AE2 VersionChecker", new Thread( VersionChecker.instance = new VersionChecker() ) );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
2014-03-30 00:36:37 +01:00
|
|
|
AELog.info( "PreInit ( end " + star.elapsed( TimeUnit.MILLISECONDS ) + "ms )" );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
void Init(FMLInitializationEvent event)
|
|
|
|
{
|
2014-03-30 00:36:37 +01:00
|
|
|
Stopwatch star = Stopwatch.createStarted();
|
2013-12-27 23:59:59 +01:00
|
|
|
AELog.info( "Init" );
|
|
|
|
|
|
|
|
Registration.instance.Init( event );
|
2014-04-06 08:55:24 +02:00
|
|
|
IntegrationRegistry.instance.init();
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-03-30 00:36:37 +01:00
|
|
|
AELog.info( "Init ( end " + star.elapsed( TimeUnit.MILLISECONDS ) + "ms )" );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
void PostInit(FMLPostInitializationEvent event)
|
|
|
|
{
|
2014-03-30 00:36:37 +01:00
|
|
|
Stopwatch star = Stopwatch.createStarted();
|
2013-12-27 23:59:59 +01:00
|
|
|
AELog.info( "PostInit" );
|
|
|
|
|
|
|
|
Registration.instance.PostInit( event );
|
2014-04-06 08:55:24 +02:00
|
|
|
IntegrationRegistry.instance.postinit();
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-02-09 06:08:27 +01:00
|
|
|
AEConfig.instance.save();
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-02-09 02:34:52 +01:00
|
|
|
NetworkRegistry.INSTANCE.registerGuiHandler( this, GuiBridge.GUI_Handler );
|
|
|
|
NetworkHandler.instance = new NetworkHandler( "AE2" );
|
|
|
|
|
2014-03-30 00:36:37 +01:00
|
|
|
AELog.info( "PostInit ( end " + star.elapsed( TimeUnit.MILLISECONDS ) + "ms )" );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
2014-04-18 04:52:39 +02:00
|
|
|
@EventHandler
|
|
|
|
public void processIMC(FMLInterModComms.IMCEvent event)
|
|
|
|
{
|
|
|
|
for (IMCMessage m : event.getMessages())
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
IIMCHandler handler = IMCHandlers.get( m.key );
|
|
|
|
if ( handler != null )
|
|
|
|
handler.post( m );
|
|
|
|
else
|
|
|
|
throw new RuntimeException( "Invalid IMC Called: " + m.key );
|
|
|
|
}
|
|
|
|
catch (Throwable t)
|
|
|
|
{
|
|
|
|
AELog.warning( "Problem detected when processing IMC " + m.key + " from " + m.getSender() );
|
|
|
|
AELog.error( t );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
@EventHandler
|
|
|
|
public void serverStopping(FMLServerStoppingEvent event)
|
|
|
|
{
|
|
|
|
WorldSettings.getInstance().shutdown();
|
|
|
|
TickHandler.instance.shutdown();
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
2014-03-30 01:23:11 +01:00
|
|
|
public void serverStarting(FMLServerAboutToStartEvent evt)
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
WorldSettings.getInstance().init();
|
2014-03-30 01:23:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void serverStarting(FMLServerStartingEvent evt)
|
|
|
|
{
|
2013-12-27 23:59:59 +01:00
|
|
|
evt.registerServerCommand( new AECommand( evt.getServer() ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|