net.minecraftforge.fml.common.Mod.EventHandler Java Examples

The following examples show how to use net.minecraftforge.fml.common.Mod.EventHandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CustomMainMenu.java    From Custom-Main-Menu with MIT License 7 votes vote down vote up
@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
	configFolder = event.getModConfigurationDirectory();
	config = new Config();
	// Load Transparent
	transparentTexture = new ResourceLocation("custommainmenu:textures/gui/transparent.png");

	EVENT_HANDLER = new CMMEventHandler();
	MinecraftForge.EVENT_BUS.register(EVENT_HANDLER);
	FMLCommonHandler.instance().bus().register(EVENT_HANDLER);

	logger = event.getModLog();

	configLoader = new ConfigurationLoader(config);

	try
	{
		configLoader.load();
	}
	catch (Exception e)
	{
		logger.log(Level.ERROR, "Error while loading config file. Will have to crash here :(.");
		throw new RuntimeException(e);
	}
}
 
Example #2
Source File: Signals.java    From Signals with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler
public void PreInit(FMLPreInitializationEvent event){
    event.getModMetadata().version = Versions.fullVersionString();
    NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy);
    proxy.preInit();
    ModBlocks.init();
    ModItems.init();
    CapabilityMinecartDestination.register();
    CapabilityDestinationProvider.register();
    MinecraftForge.EVENT_BUS.register(proxy);
    MinecraftForge.EVENT_BUS.register(new com.minemaarten.signals.event.EventHandler());
    MinecraftForge.EVENT_BUS.register(new RailReplacerEventHandler());
    BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(ModItems.TICKET, new BehaviorDispenseTicket());

    ChunkLoadManager.INSTANCE.init();

    asmData = event.getAsmData();

    if(!SignalsConfig.enableRailNetwork) {
        Log.warning("RAIL NETWORK IS NOT FUNCTIONAL!");
    }
}
 
Example #3
Source File: WorldRetrogen.java    From simpleretrogen with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler
public void serverStopped(FMLServerStoppedEvent evt)
{
    Set<IWorldGenerator> worldGens = ObfuscationReflectionHelper.getPrivateValue(GameRegistry.class, null, "worldGenerators");
    Map<IWorldGenerator,Integer> worldGenIdx = ObfuscationReflectionHelper.getPrivateValue(GameRegistry.class, null, "worldGeneratorIndex");

    for (TargetWorldWrapper tww : delegates.values())
    {
        worldGens.remove(tww);
        Integer idx = worldGenIdx.remove(tww);
        worldGens.add(tww.delegate);
        worldGenIdx.put(tww.delegate,idx);
    }

    delegates.clear();
}
 
Example #4
Source File: BaseMetals.java    From BaseMetals with GNU Lesser General Public License v2.1 6 votes vote down vote up
@EventHandler
public void init(FMLInitializationEvent event)
{

	cyano.basemetals.init.Recipes.init();
	cyano.basemetals.init.DungeonLoot.init();
	cyano.basemetals.init.Entities.init();
	
	cyano.basemetals.init.Achievements.init();


	if(event.getSide() == Side.CLIENT){
		clientInit(event);
	}
	if(event.getSide() == Side.SERVER){
		serverInit(event);
	}
}
 
Example #5
Source File: TeleportMod.java    From ModdingTutorials with GNU General Public License v2.0 5 votes vote down vote up
@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
	TeleportBlocks.init();
	TeleportBlocks.register();
	TeleportItems.init();
	TeleportItems.register();
	TeleportTileEntities.register();
}
 
Example #6
Source File: AdvancedRocketry.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@EventHandler
public void serverStopped(FMLServerStoppedEvent event) {
	zmaster587.advancedRocketry.dimension.DimensionManager.getInstance().unregisterAllDimensions();
	zmaster587.advancedRocketry.cable.NetworkRegistry.clearNetworks();
	SpaceObjectManager.getSpaceManager().onServerStopped();
	zmaster587.advancedRocketry.api.Configuration.MoonId = -1;
	DimensionManager.getInstance().overworldProperties.resetProperties();
	((BlockSeal)AdvancedRocketryBlocks.blockPipeSealer).clearMap();
	DimensionManager.dimOffset = config.getInt("minDimension", PLANET, 2, -127, 8000, "Dimensions including and after this number are allowed to be made into planets");
	
	DimensionManager.getInstance().knownPlanets.clear();
	
	if(!zmaster587.advancedRocketry.api.Configuration.lockUI)
		proxy.saveUILayout(config);
}
 
Example #7
Source File: CommunityMod.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@EventHandler
public void onConstruction (FMLConstructionEvent event) {

    config = new CommunityConfig(new File("config/" + CommunityGlobals.MOD_ID + ".cfg"));
    SubModLoader.INSTANCE.onConstruction(event);
    config.syncConfigData();
}
 
Example #8
Source File: CommunityMod.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@EventHandler
public void onInit (FMLInitializationEvent event) {

    for (final SubModContainer container : SubModLoader.getLoadedSubMods()) {

        activeSubMod = container;
        container.getSubMod().onInit(event);
    }

    activeSubMod = null;
}
 
Example #9
Source File: CommunityMod.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@EventHandler
public void onLoadComplete (FMLLoadCompleteEvent event) {

    for (final SubModContainer container : SubModLoader.getLoadedSubMods()) {

        activeSubMod = container;
        container.getSubMod().onLoadComplete(event);
    }

    activeSubMod = null;
}
 
Example #10
Source File: CommunityMod.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@EventHandler
public void onServerStarting (FMLServerStartingEvent event) {

    for (final SubModContainer container : SubModLoader.getLoadedSubMods()) {

        activeSubMod = container;
        container.getSubMod().onServerStarting(event);
    }

    activeSubMod = null;
}
 
Example #11
Source File: EnderZoo.java    From EnderZoo with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
@EventHandler
public void postInit(FMLPostInitializationEvent event) {

  MobSpawns.instance.loadSpawnConfig();

  if (Config.enderZooDifficultyModifierEnabled || Config.globalDifficultyModifierEnabled) {
    spawnEventHandler = new MobSpawnEventHandler();
    spawnEventHandler.init();
  }

}
 
Example #12
Source File: TeleportMod.java    From ModdingTutorials with GNU General Public License v2.0 5 votes vote down vote up
@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
	TeleportBlocks.init();
	TeleportBlocks.register();
	TeleportItems.init();
	TeleportItems.register();
	TeleportTileEntities.register();
}
 
Example #13
Source File: YUNoMakeGoodMap.java    From YUNoMakeGoodMap with Apache License 2.0 5 votes vote down vote up
@EventHandler
public void load(FMLInitializationEvent event)
{
    FMLLog.log(Level.INFO, "YUNoMakeGoodMap Initalized");
    worldType = new VoidWorldType();

    DimensionManager.unregisterDimension(-1);
    DimensionManager.unregisterDimension(0);
    DimensionManager.unregisterDimension(1);
    DimensionManager.registerDimension(-1, DimensionType.register("Nether", "_nether", -1, WorldProviderHellVoid.class, false));
    DimensionManager.registerDimension(0,  DimensionType.register("Overworld", "", 0, WorldProviderSurfaceVoid.class, true));
    DimensionManager.registerDimension(1,  DimensionType.register("The End", "_end", 1, WorldProviderEndVoid.class, false));
}
 
Example #14
Source File: Mobycraft.java    From mobycraft with Apache License 2.0 5 votes vote down vote up
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
	File configFile = new File(event.getModConfigurationDirectory()
			.toString() + "/mobycraft/mobycraft.txt");

	config = new Configuration(configFile);
	config.load();
	config.getString(
			"docker-cert-path",
			"files",
			"File path",
			"The directory path of your Docker certificate (set using /docker path <path>); only used if DOCKER_CERT_PATH environment variable is not set");
	config.getString(
			"docker-host",
			"files",
			"Docker host IP",
			"The IP of your Docker host (set using /docker host <host>); only used if DOCKER_HOST environment variable is not set");
	config.getString(
			"start-pos",
			"container-building",
			"0, 0, 0",
			"The position - x, y, z - to start building containers at (set using /docker start_pos)");
	config.getString(
			"poll-rate",
			"container-building",
			"2",
			"The rate in seconds at which the containers will update (set using /docker poll_rate <rate in seconds>)");
	config.save();
}
 
Example #15
Source File: ToroQuest.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
public void preInit(FMLPreInitializationEvent e) {
	proxy.preInit(e);

	ConfigurationHandler.init(e.getSuggestedConfigurationFile());
	MinecraftForge.EVENT_BUS.register(new ConfigurationHandler());
}
 
Example #16
Source File: CraftingKeys.java    From CraftingKeys with MIT License 5 votes vote down vote up
/**
 * This method will be executed while loading.
 *
 * @param event Input Event from FML
 */
@EventHandler
public void load(FMLInitializationEvent event) {

    // Registering
    FMLCommonHandler.instance().bus().register(this);
    MinecraftForge.EVENT_BUS.register(this);
    NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiConfigHandler());
    KeyBindings.init();
    Logger.info("load(e)", "Registered Mod.");

}
 
Example #17
Source File: CraftingKeys.java    From CraftingKeys with MIT License 5 votes vote down vote up
/**
 * This method will be executed before Init.
 *
 * @param event Input Event from FML
 */
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
    Logger.info("preInit(e)", "Loading Config now.");
    Config.loadConfig(event);
    Logger.info("preInit(e)", "Finished loading Config.");
}
 
Example #18
Source File: AdvancedRocketry.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@EventHandler
public void serverStarted(FMLServerStartedEvent event) {
	for (int dimId : DimensionManager.getInstance().getLoadedDimensions()) {
		DimensionProperties properties = DimensionManager.getInstance().getDimensionProperties(dimId);
		if(!properties.isNativeDimension && properties.getId() == zmaster587.advancedRocketry.api.Configuration.MoonId && !Loader.isModLoaded("GalacticraftCore")) {
			properties.isNativeDimension = true;
		}
	}
}
 
Example #19
Source File: ValkyrienSkiesWorld.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@EventHandler
protected void init(FMLInitializationEvent event) {
    EntityRegistry.registerModEntity(
        new ResourceLocation(ValkyrienSkiesWorld.MOD_ID, "fall_up_block_entity"),
        EntityFallingUpBlock.class,
        "fall_up_block_entity",
        75, ValkyrienSkiesWorld.INSTANCE, 80, 1, true);

    MinecraftForge.EVENT_BUS.register(worldEventsCommon);
    GameRegistry.registerWorldGenerator(new ValkyrienSkiesWorldGen(), 1);
    proxy.init(event);
}
 
Example #20
Source File: ValkyrienSkiesMod.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@Mod.EventHandler
public void onFingerprintViolation(FMLFingerprintViolationEvent event) {
    if (MixinLoaderForge.isObfuscatedEnvironment) { //only print signature warning in obf
        FMLLog.bigWarning(
            "Valkyrien Skies JAR fingerprint corrupted, which means this copy of the mod "
                + "may have come from unofficial sources. Please check out our official website: "
                + "https://valkyrienskies.org");
    }
}
 
Example #21
Source File: ValkyrienSkiesMod.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
    log.debug("Initializing configuration");
    runConfiguration();

    log.debug("Instantiating the physics thread executor");
    ValkyrienSkiesMod.PHYSICS_THREADS_EXECUTOR = Executors
        .newFixedThreadPool(VSConfig.threadCount);

    log.debug("Beginning asynchronous Kryo initialization");
    serializationInitAsync();
    registerNetworks(event);

    registerCapabilities();
    proxy.preInit(event);

    log.debug("Initializing the VS API");
    try {
        Field instanceField = IPhysicsEntityManager.class.getDeclaredField("INSTANCE");
        // Make the field accessible
        instanceField.setAccessible(true);
        // Remove the final modifier
        Field modifiersField = Field.class.getDeclaredField("modifiers");
        modifiersField.setAccessible(true);
        modifiersField.setInt(instanceField, instanceField.getModifiers() & ~Modifier.FINAL);
        // Finally set the new value of the field.
        instanceField.set(null, new VS_APIPhysicsEntityManager());
    } catch (Exception e) {
        e.printStackTrace();
        log.fatal("FAILED TO INITIALIZE VS API!");
    }
    // Initialize VS API end.
}
 
Example #22
Source File: ValkyrienSkiesMod.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@EventHandler
public void init(FMLInitializationEvent event) {
    // Print out a message of core count, we want this to know what AnvilNode is giving us.
    log.info("Valkyrien Skies Initialization:");
    log.info("We are running on " + Runtime.getRuntime().availableProcessors() +
        " threads; 4 or more is recommended!");
    proxy.init(event);
}
 
Example #23
Source File: MalmoMod.java    From malmo with MIT License 5 votes vote down vote up
@EventHandler
public void onMissingMappingsEvent(FMLMissingMappingsEvent event)
{
    // The lit_furnace item was removed in Minecraft 1.9, so pre-1.9 files will produce a warning when
    // loaded. This is harmless for a human user, but it breaks Malmo's FileWorldGenerator handler, since
    // it will bring up a GUI and wait for the user to click a button before continuing.
    // To avoid this, we specifically ignore lit_furnace item mapping.
    for (MissingMapping mapping : event.getAll())
    {
        if (mapping.type == GameRegistry.Type.ITEM && mapping.name.equals("minecraft:lit_furnace"))
            mapping.ignore();
    }
}
 
Example #24
Source File: MalmoMod.java    From malmo with MIT License 5 votes vote down vote up
@EventHandler
public void init(FMLInitializationEvent event)
{
    if (event.getSide().isClient())
    {
        this.client = new MalmoModClient();
        this.client.init(event);
    }
    if (event.getSide().isServer())
    {
        this.server = new MalmoModServer();
        this.server.init(event);
    }
}
 
Example #25
Source File: ExNihiloAdscensio.java    From ExNihiloAdscensio with MIT License 5 votes vote down vote up
@EventHandler
public static void preInit(FMLPreInitializationEvent event) {
	LogUtil.setup();

	configDirectory = new File(event.getModConfigurationDirectory(), "exnihiloadscensio");
	configDirectory.mkdirs();

	Config.doNormalConfig(new File(configDirectory, "ExNihiloAdscensio.cfg"));

	ENCapabilities.init();
	ENItems.init();
	ENBlocks.init();
	ENEntities.init();
	ENEnchantments.init();
	proxy.initModels();
	proxy.registerRenderers();
	
	defaultRecipes = new ExNihiloDefaultRecipes();

	MinecraftForge.EVENT_BUS.register(new HandlerHammer());

	MinecraftForge.EVENT_BUS.register(new HandlerCrook());

	if (Config.enableBarrels) {
		BarrelModeRegistry.registerDefaults();
	}

	PacketHandler.initPackets();
}
 
Example #26
Source File: EnderZoo.java    From EnderZoo with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
@EventHandler
 public void preInit(FMLPreInitializationEvent event) {
  
MinecraftForge.EVENT_BUS.register(new RegistryHandler());
  
   itemForCreativeMenuIcon = ItemForCreativeMenuIcon.create();

   Config.load(event);
   
   itemWitheringDust = ItemWitheringDust.create();
   itemConfusingDust = ItemConfusingDust.create();
   itemEnderFragment = ItemEnderFragment.create();
   itemGuardiansBow = ItemGuardiansBow.create();   
   itemOwlEgg = ItemOwlEgg.create();

   if (Config.confusingChargeEnabled) {
     blockConfusingCharge = BlockConfusingCharge.create();
   }
   if (Config.enderChargeEnabled) {
     blockEnderCharge = BlockEnderCharge.create();
   }
   if (Config.concussionChargeEnabled) {
     blockConcussionCharge = BlockConcussionCharge.create();
   }
   potions = new Potions();

   FMLInterModComms.sendMessage("waila", "register", "crazypants.enderzoo.waila.WailaCompat.load");
   proxy.preInit();
 }
 
Example #27
Source File: ExNihiloAdscensio.java    From ExNihiloAdscensio with MIT License 5 votes vote down vote up
@EventHandler
public static void postInit(FMLPostInitializationEvent event) {

	if (Loader.isModLoaded("tconstruct") && Config.doTICCompat) {
		CompatTConstruct.postInit();
	}
	if (Loader.isModLoaded("EnderIO") && Config.doEnderIOCompat) {
		CompatEIO.postInit();
	}
	
}
 
Example #28
Source File: TinkerToolLeveling.java    From TinkersToolLeveling with MIT License 5 votes vote down vote up
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
  modConfigurationDirectory = event.getModConfigurationDirectory();
  networkWrapper = new NetworkWrapper("tinkerlevel" + ":sync");
  networkWrapper.registerPacketClient(ConfigSyncPacket.class);

  CapabilityDamageXp.register();

  MinecraftForge.EVENT_BUS.register(this);
}
 
Example #29
Source File: TFC.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
public void serverStarting(FMLServerStartingEvent evt)
{
	evt.registerServerCommand(new PrintImageMapCommand());
	evt.registerServerCommand(new TeleportInIslandCommand());
	evt.registerServerCommand(new RemoveAreaCommand());
	evt.registerServerCommand(new StripChunkCommand());
	evt.registerServerCommand(new RegenChunkCommand());
	evt.registerServerCommand(new DebugCommand());
}
 
Example #30
Source File: Signals.java    From Signals with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
public void postInit(FMLPostInitializationEvent event){
    proxy.postInit();
    RailManager.getInstance().initializeAPIImplementors(asmData);
    SignalsConfig.client.networkVisualization.initDefaults();
    ConfigManager.sync(Constants.MOD_ID, Type.INSTANCE);
}