2014-11-13 14:48:04 +01:00
|
|
|
/*
|
|
|
|
* This file is part of Applied Energistics 2.
|
|
|
|
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
|
|
|
*
|
|
|
|
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
|
|
|
*/
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
package appeng.core;
|
|
|
|
|
2014-11-13 14:48:04 +01:00
|
|
|
|
2014-02-11 06:50:05 +01:00
|
|
|
import java.io.File;
|
2014-03-30 00:36:37 +01:00
|
|
|
import java.util.concurrent.TimeUnit;
|
2014-02-11 06:50:05 +01:00
|
|
|
|
2014-12-29 21:59:05 +01:00
|
|
|
import com.google.common.base.Stopwatch;
|
|
|
|
|
2014-11-13 14:48:04 +01:00
|
|
|
import cpw.mods.fml.common.FMLCommonHandler;
|
|
|
|
import cpw.mods.fml.common.Loader;
|
|
|
|
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.FMLInterModComms;
|
|
|
|
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;
|
|
|
|
import cpw.mods.fml.common.network.NetworkRegistry;
|
|
|
|
|
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;
|
2014-07-24 00:26:23 +02:00
|
|
|
import appeng.integration.IntegrationType;
|
2014-08-22 07:27:46 +02:00
|
|
|
import appeng.server.AECommand;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.services.VersionChecker;
|
|
|
|
import appeng.util.Platform;
|
2014-03-30 00:36:37 +01:00
|
|
|
|
|
|
|
|
2014-11-28 04:36:46 +01:00
|
|
|
@Mod( modid = AppEng.MOD_ID, acceptedMinecraftVersions = "[1.7.10]", name = AppEng.MOD_NAME, version = AEConfig.VERSION, dependencies = AppEng.MOD_DEPENDENCIES, guiFactory = "appeng.client.gui.config.AEConfigGuiFactory" )
|
2013-12-27 23:59:59 +01:00
|
|
|
public class AppEng
|
|
|
|
{
|
2014-11-28 04:36:46 +01:00
|
|
|
public final static String MOD_ID = "appliedenergistics2";
|
|
|
|
public final static String MOD_NAME = "Applied Energistics 2";
|
|
|
|
public final static String MOD_DEPENDENCIES =
|
2014-11-13 14:48:04 +01:00
|
|
|
// a few mods, AE should load after, probably.
|
|
|
|
// required-after:AppliedEnergistics2API|all;
|
|
|
|
// "after:gregtech_addon;after:Mekanism;after:IC2;after:ThermalExpansion;after:BuildCraft|Core;" +
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-11-13 14:48:04 +01:00
|
|
|
// depend on version of forge used for build.
|
|
|
|
"after:appliedenergistics2-core;" + "required-after:Forge@[" // require forge.
|
2014-11-28 04:36:46 +01:00
|
|
|
+ net.minecraftforge.common.ForgeVersion.majorVersion + '.' // majorVersion
|
|
|
|
+ net.minecraftforge.common.ForgeVersion.minorVersion + '.' // minorVersion
|
|
|
|
+ net.minecraftforge.common.ForgeVersion.revisionVersion + '.' // revisionVersion
|
2014-11-13 14:48:04 +01:00
|
|
|
+ net.minecraftforge.common.ForgeVersion.buildVersion + ",)"; // buildVersion
|
2014-11-27 17:06:48 +01:00
|
|
|
public static AppEng instance;
|
2014-11-28 04:36:46 +01:00
|
|
|
|
2014-11-27 17:06:48 +01:00
|
|
|
private final IMCHandler imcHandler;
|
2014-11-28 04:36:46 +01:00
|
|
|
|
2014-11-27 17:06:48 +01:00
|
|
|
private String configPath;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-11-13 14:48:04 +01:00
|
|
|
public AppEng()
|
|
|
|
{
|
2013-12-27 23:59:59 +01:00
|
|
|
instance = this;
|
|
|
|
|
2014-11-27 17:06:48 +01:00
|
|
|
this.imcHandler = new IMCHandler();
|
2014-04-18 04:52:39 +02:00
|
|
|
|
2014-05-13 04:15:31 +02:00
|
|
|
FMLCommonHandler.instance().registerCrashCallable( new CrashEnhancement( CrashInfo.MOD_VERSION ) );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
2014-11-27 17:06:48 +01:00
|
|
|
public String getConfigPath()
|
|
|
|
{
|
2014-11-28 04:36:46 +01:00
|
|
|
return this.configPath;
|
2014-11-27 17:06:48 +01:00
|
|
|
}
|
|
|
|
|
2014-11-28 04:36:46 +01:00
|
|
|
public boolean isIntegrationEnabled( IntegrationType integrationName )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-11-28 04:36:46 +01:00
|
|
|
return IntegrationRegistry.INSTANCE.isEnabled( integrationName );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
2014-11-28 04:36:46 +01:00
|
|
|
public Object getIntegration( IntegrationType integrationName )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-11-28 04:36:46 +01:00
|
|
|
return IntegrationRegistry.INSTANCE.getInstance( integrationName );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
2014-11-28 04:36:46 +01:00
|
|
|
void preInit( FMLPreInitializationEvent event )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-08-03 06:53:46 +02:00
|
|
|
if ( !Loader.isModLoaded( "appliedenergistics2-core" ) )
|
2014-08-03 19:00:53 +02:00
|
|
|
{
|
|
|
|
CommonHelper.proxy.missingCoreMod();
|
|
|
|
}
|
2014-08-03 06:34:49 +02:00
|
|
|
|
2014-03-30 00:36:37 +01:00
|
|
|
Stopwatch star = Stopwatch.createStarted();
|
2014-11-28 04:36:46 +01:00
|
|
|
this.configPath = event.getModConfigurationDirectory().getPath() + File.separator + "AppliedEnergistics2" + File.separator;
|
2014-02-11 06:50:05 +01:00
|
|
|
|
2014-11-28 04:36:46 +01:00
|
|
|
AEConfig.instance = new AEConfig( this.configPath );
|
|
|
|
FacadeConfig.instance = new FacadeConfig( this.configPath );
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-12-20 22:16:11 +01:00
|
|
|
AELog.info( "Pre Initialization ( started )" );
|
2014-02-07 21:56:50 +01:00
|
|
|
|
2014-06-29 03:32:07 +02:00
|
|
|
CreativeTab.init();
|
2014-06-13 20:41:50 +02:00
|
|
|
if ( AEConfig.instance.isFeatureEnabled( AEFeature.Facades ) )
|
|
|
|
CreativeTabFacade.init();
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
if ( Platform.isClient() )
|
|
|
|
CommonHelper.proxy.init();
|
|
|
|
|
2014-12-29 12:48:22 +01:00
|
|
|
Registration.INSTANCE.preInitialize( event );
|
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-11-28 04:36:46 +01:00
|
|
|
this.startService( "AE2 VersionChecker", new Thread( new VersionChecker() ) );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
2014-12-20 22:16:11 +01:00
|
|
|
AELog.info( "Pre Initialization ( ended after " + star.elapsed( TimeUnit.MILLISECONDS ) + "ms )" );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
2014-11-27 17:06:48 +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
|
2014-11-28 04:36:46 +01:00
|
|
|
void init( FMLInitializationEvent event )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-03-30 00:36:37 +01:00
|
|
|
Stopwatch star = Stopwatch.createStarted();
|
2014-12-20 22:16:11 +01:00
|
|
|
AELog.info( "Initialization ( started )" );
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-12-29 12:48:22 +01:00
|
|
|
Registration.INSTANCE.initialize( event );
|
2014-11-13 14:48:04 +01:00
|
|
|
IntegrationRegistry.INSTANCE.init();
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-12-20 22:16:11 +01:00
|
|
|
AELog.info( "Initialization ( ended after " + star.elapsed( TimeUnit.MILLISECONDS ) + "ms )" );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
2014-11-28 04:36:46 +01:00
|
|
|
void postInit( FMLPostInitializationEvent event )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-03-30 00:36:37 +01:00
|
|
|
Stopwatch star = Stopwatch.createStarted();
|
2014-12-20 22:16:11 +01:00
|
|
|
AELog.info( "Post Initialization ( started )" );
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-12-29 12:48:22 +01:00
|
|
|
Registration.INSTANCE.postInit( event );
|
2014-11-13 14:48:04 +01:00
|
|
|
IntegrationRegistry.INSTANCE.postInit();
|
2014-05-13 04:15:31 +02:00
|
|
|
FMLCommonHandler.instance().registerCrashCallable( new CrashEnhancement( CrashInfo.INTEGRATION ) );
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-09-28 11:47:17 +02:00
|
|
|
CommonHelper.proxy.postInit();
|
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-12-20 22:16:11 +01:00
|
|
|
AELog.info( "Post Initialization ( ended after " + star.elapsed( TimeUnit.MILLISECONDS ) + "ms )" );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
2014-04-18 04:52:39 +02:00
|
|
|
@EventHandler
|
2014-11-27 17:06:48 +01:00
|
|
|
public void handleIMCEvent( FMLInterModComms.IMCEvent event )
|
2014-04-18 04:52:39 +02:00
|
|
|
{
|
2014-11-27 17:06:48 +01:00
|
|
|
this.imcHandler.handleIMCEvent( event );
|
2014-04-18 04:52:39 +02:00
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
@EventHandler
|
2014-11-13 14:48:04 +01:00
|
|
|
public void serverStopping( FMLServerStoppingEvent event )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
WorldSettings.getInstance().shutdown();
|
2015-01-01 22:13:10 +01:00
|
|
|
TickHandler.INSTANCE.shutdown();
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
2014-11-13 14:48:04 +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
|
|
|
}
|
|
|
|
|
2014-08-22 07:27:46 +02:00
|
|
|
@EventHandler
|
2014-11-13 14:48:04 +01:00
|
|
|
public void serverStarting( FMLServerStartingEvent evt )
|
2014-08-22 07:27:46 +02:00
|
|
|
{
|
|
|
|
evt.registerServerCommand( new AECommand( evt.getServer() ) );
|
|
|
|
}
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|