/** * Called before the load event. * * @param event * @throws Exception */ @EventHandler public void preInit( final FMLPreInitializationEvent event ) throws Exception { // Mark that ThE is in PreInit long startTime = ThELog.beginSection( "PreInit" ); // Set the instance ThaumicEnergistics.INSTANCE = this; // Sync with config ThaumicEnergistics.config = ConfigurationHandler.loadAndSyncConfigFile( event.getSuggestedConfigurationFile() ); // Register the gui handler NetworkRegistry.INSTANCE.registerGuiHandler( this, new ThEGuiHandler() ); // Register items ThaumicEnergistics.proxy.registerItems(); // Register blocks ThaumicEnergistics.proxy.registerBlocks(); // Mark that ThE has finished PreInit ThELog.endSection( "PreInit", startTime ); ThaumicEnergistics.ThEState = LoaderState.PREINITIALIZATION; }
public static void newItemAdded(Item item) { ModContainer mc = Loader.instance().activeModContainer(); if (mc == null) { mc = Loader.instance().getMinecraftModContainer(); if (Loader.instance().hasReachedState(LoaderState.INITIALIZATION) || validated) { FMLLog.severe("It appears something has tried to allocate an Item or Block outside of the preinitialization phase for mods. This will NOT work in 1.7 and beyond!"); } } String itemType = item.getClass().getName(); ItemData itemData = new ItemData(item, mc); if (idMap.containsKey(item.field_77779_bT)) { ItemData id = idMap.get(item.field_77779_bT); FMLLog.log("fml.ItemTracker", Level.INFO, "The mod %s is overwriting existing item at %d (%s from %s) with %s", mc.getModId(), id.getItemId(), id.getItemType(), id.getModId(), itemType); } idMap.put(item.field_77779_bT, itemData); if (!"Minecraft".equals(mc.getModId())) { FMLLog.log("fml.ItemTracker",Level.FINE, "Adding item %s(%d) owned by %s", item.getClass().getName(), item.field_77779_bT, mc.getModId()); } }
public static void newItemAdded(Item item) { ModContainer mc = Loader.instance().activeModContainer(); if (mc == null) { mc = Loader.instance().getMinecraftModContainer(); if (Loader.instance().hasReachedState(LoaderState.INITIALIZATION) || validated) { FMLLog.severe("It appears something has tried to allocate an Item or Block outside of the preinitialization phase for mods. This will NOT work in 1.7 and beyond!"); } } String itemType = item.getClass().getName(); ItemData itemData = new ItemData(item, mc); if (idMap.containsKey(item.itemID)) { ItemData id = idMap.get(item.itemID); FMLLog.log("fml.ItemTracker", Level.INFO, "The mod %s is overwriting existing item at %d (%s from %s) with %s", mc.getModId(), id.getItemId(), id.getItemType(), id.getModId(), itemType); } idMap.put(item.itemID, itemData); if (!"Minecraft".equals(mc.getModId())) { FMLLog.log("fml.ItemTracker",Level.FINE, "Adding item %s(%d) owned by %s", item.getClass().getName(), item.itemID, mc.getModId()); } }
private static boolean enqueueStartupMessage(String modTarget, IMCMessage message) { if (Loader.instance().activeModContainer() == null) { return false; } enqueueMessage(Loader.instance().activeModContainer(), modTarget, message); return Loader.isModLoaded(modTarget) && !Loader.instance().hasReachedState(LoaderState.POSTINITIALIZATION); }
public static boolean isIc2Available() { if (ic2Available != null) return ic2Available; boolean loaded = Loader.isModLoaded("IC2"); if (Loader.instance().hasReachedState(LoaderState.CONSTRUCTING)) { ic2Available = loaded; } return loaded; }
public static boolean isIc2Available() { if (ic2Available != null) { return ic2Available; } boolean loaded = Loader.isModLoaded("IC2"); if (Loader.instance().hasReachedState(LoaderState.CONSTRUCTING)) { ic2Available = loaded; } return loaded; }
/** * Checks if ThE has finished the preinit phase. * * @return */ protected static boolean hasFinishedPreInit() { // Ensure that ThE has finished the PreInit phase if( ThaumicEnergistics.getLoaderState() == LoaderState.NOINIT ) { // Invalid state, API can not yet load. ThELog.warning( "API is not available until ThE finishes the PreInit phase." ); return false; } return true; }
/** * Called after the preInit event, and before the post init event. * * @param event */ @EventHandler public void load( final FMLInitializationEvent event ) { // Mark that ThE is in Init long startTime = ThELog.beginSection( "Load" ); // Register block renderers ThaumicEnergistics.proxy.registerRenderers(); // Register tile entities ThaumicEnergistics.proxy.registerTileEntities(); // Register packets NetworkHandler.registerPackets(); // Register integration IntegrationCore.init(); // Register the essentia grid cache AEApi.instance().registries().gridCache().registerGridCache( IEssentiaGrid.class, GridEssentiaCache.class ); // Register the wireless golem handler ThEApi.instance().interact().registerGolemHookHandler( WirelessGolemHandler.getInstance() ); // Mark that ThE has finished Init ThELog.endSection( "Load", startTime ); ThaumicEnergistics.ThEState = LoaderState.INITIALIZATION; }
/** * Called after the load event. * * @param event */ @EventHandler public void postInit( final FMLPostInitializationEvent event ) { // Mark that ThE is in PostInit long startTime = ThELog.beginSection( "PostInit" ); // Register the standard thaumcraft container items and tiles EssentiaTileContainerHelper.INSTANCE.registerDefaultContainers(); EssentiaItemContainerHelper.INSTANCE.registerDefaultContainers(); // Register features ThaumicEnergistics.proxy.registerFeatures(); // Register my tiles with SpatialIO ThaumicEnergistics.proxy.registerSpatialIOMovables(); // Register fluids ThaumicEnergistics.proxy.registerFluids(); // Give AE items aspects try { AEAspectRegister.INSTANCE.registerAEAspects(); } catch( Exception e ) { ThELog.warning( "Unable to finish aspect registration due to exception:%n%s%n", e.getMessage() ); } // Mark that ThE has finished PostInit ThELog.endSection( "PostInit", startTime ); ThaumicEnergistics.ThEState = LoaderState.POSTINITIALIZATION; }
/** Returns the mod ID of the currently active mod. <br> * <b>Warning:</b> Only use during FML events preinit, init, postinit and similar. */ public static String getActiveModId() { if (Loader.instance().hasReachedState(LoaderState.AVAILABLE)) throw new RuntimeException("getActiveModId can't be called after mods have been initialized!"); return Loader.instance().activeModContainer().getModId(); }
public void stopServer() throws MinecraftException // CraftBukkit - added throws { if (!this.worldIsBeingDeleted && Loader.instance().hasReachedState(LoaderState.SERVER_STARTED) && !serverStopped) // make sure the save is valid and we don't save twice { logger.info("Stopping server"); // CraftBukkit start if (this.server != null) { this.server.disablePlugins(); } // CraftBukkit end if (this.func_147137_ag() != null) { this.func_147137_ag().terminateEndpoints(); } if (this.serverConfigManager != null) { logger.info("Saving players"); this.serverConfigManager.saveAllPlayerData(); this.serverConfigManager.removeAllPlayers(); } if (this.worldServers != null) { logger.info("Saving worlds"); try { this.saveAllWorlds(false); } catch (MinecraftException e) { e.printStackTrace(); } for (int i = 0; i < this.worldServers.length; ++i) { WorldServer worldserver = this.worldServers[i]; MinecraftForge.EVENT_BUS.post(new WorldEvent.Unload(worldserver)); worldserver.flush(); } WorldServer[] tmp = worldServers; for (WorldServer world : tmp) { DimensionManager.setWorld(world.provider.dimensionId, null); } } if (this.usageSnooper.isSnooperRunning()) { this.usageSnooper.stopSnooper(); } } }
public void stopServer() { if (!this.worldIsBeingDeleted && Loader.instance().hasReachedState(LoaderState.SERVER_STARTED) && !serverStopped) // make sure the save is valid and we don't save twice { logger.info("Stopping server"); if (this.func_147137_ag() != null) { this.func_147137_ag().terminateEndpoints(); } if (this.serverConfigManager != null) { logger.info("Saving players"); this.serverConfigManager.saveAllPlayerData(); this.serverConfigManager.removeAllPlayers(); } if (this.worldServers != null) { logger.info("Saving worlds"); this.saveAllWorlds(false); for (int i = 0; i < this.worldServers.length; ++i) { WorldServer worldserver = this.worldServers[i]; MinecraftForge.EVENT_BUS.post(new WorldEvent.Unload(worldserver)); worldserver.flush(); } WorldServer[] tmp = worldServers; for (WorldServer world : tmp) { DimensionManager.setWorld(world.provider.dimensionId, null); } } if (this.usageSnooper.isSnooperRunning()) { this.usageSnooper.stopSnooper(); } } }
/** * Gets what state/phase of loading that ThE has <strong>completed</strong>.<br> * NOINIT: PreInit has not yet been called<br> * PREINITIALIZATION: PreInit has finished.<br> * INITIALIZATION: Load has finished.<br> * POSTINITIALIZATION: PostInit has finished, ThE is fully loaded. * * @return */ public static LoaderState getLoaderState() { return ThaumicEnergistics.ThEState; }