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

The following examples show how to use net.minecraftforge.fml.common.Mod.EventHandler. These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: Custom-Main-Menu   Source File: CustomMainMenu.java    License: MIT License 6 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 Project: Signals   Source File: Signals.java    License: 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 Project: BaseMetals   Source File: BaseMetals.java    License: 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 4
Source Project: simpleretrogen   Source File: WorldRetrogen.java    License: 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 5
Source Project: TofuCraftReload   Source File: TofuMain.java    License: MIT License 5 votes vote down vote up
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
    proxy.preInit(event);

    logger = event.getModLog();

    TofuEntityRegister.entitySpawn();

    TofuCompat.preInit();

    GameRegistry.registerWorldGenerator(new TofuOreGenerator(), 0);

    MapGenStructureIO.registerStructure(MapGenTofuVillage.Start.class,"TofuVillage");
    StructureTofuVillagePieces.registerVillagePieces();
    MapGenStructureIO.registerStructure(StructureTofuMineshaftStart.class,"TofuMineshaft");
    StructureTofuMineshaftPieces.registerStructurePieces();
    MapGenStructureIO.registerStructure(MapGenTofuCastle.Start.class, "TofuCastle");
    TofuCastlePiece.registerTofuCastlePiece();

    NetworkRegistry.INSTANCE.registerGuiHandler(this, new TofuGuiHandler());


    zunda = new DamageSource("zunda") {
        @Override
        public ITextComponent getDeathMessage(EntityLivingBase entityLivingBaseIn) {
            String s = "death.attack.zunda";
            String s1 = s + ".player";

            return new TextComponentString(entityLivingBaseIn.getDisplayName().getFormattedText() + " ").appendSibling(new TextComponentTranslation(s1, new Object[]{entityLivingBaseIn.getDisplayName()}));
        }
    }.setDamageIsAbsolute();

    TOFU_DIMENSION = DimensionType.register("Tofu World", "_tofu", TofuConfig.dimensionID, WorldProviderTofu.class, false);
    DimensionManager.registerDimension(TofuConfig.dimensionID, TOFU_DIMENSION);

    TofuVillages.register();
}
 
Example 6
Source Project: WearableBackpacks   Source File: WearableBackpacks.java    License: MIT License 5 votes vote down vote up
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
	LOG = event.getModLog();
	CHANNEL = new BackpacksChannel();
	
	CONFIG = new BackpacksConfig(event.getSuggestedConfigurationFile());
	CONFIG.load();
	CONFIG.save();
	
	CONTENT = new BackpacksContent();
	CONTENT.registerRecipes();
	
	PROXY.preInit();
}
 
Example 7
@EventHandler
public void onConstruction (FMLConstructionEvent event) {

    config = new CommunityConfig(new File("config/" + CommunityGlobals.MOD_ID + ".cfg"));
    SubModLoader.INSTANCE.onConstruction(event);
    config.syncConfigData();
}
 
Example 8
@EventHandler
public void onInit (FMLInitializationEvent event) {

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

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

    activeSubMod = null;
}
 
Example 9
@EventHandler
public void onPostInit (FMLPostInitializationEvent event) {

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

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

    activeSubMod = null;
}
 
Example 10
@EventHandler
public void onLoadComplete (FMLLoadCompleteEvent event) {

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

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

    activeSubMod = null;
}
 
Example 11
@EventHandler
public void onServerStarting (FMLServerStartingEvent event) {

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

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

    activeSubMod = null;
}
 
Example 12
@EventHandler
public void onServerStopped (FMLServerStoppedEvent event) {

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

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

    activeSubMod = null;
}
 
Example 13
Source Project: YUNoMakeGoodMap   Source File: YUNoMakeGoodMap.java    License: 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 Project: mobycraft   Source File: Mobycraft.java    License: 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 Project: ToroQuest   Source File: ToroQuest.java    License: 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 Project: Valkyrien-Skies   Source File: ValkyrienSkiesWorld.java    License: 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 17
Source Project: Valkyrien-Skies   Source File: ValkyrienSkiesMod.java    License: 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 18
Source Project: Valkyrien-Skies   Source File: ValkyrienSkiesMod.java    License: 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 19
Source Project: Valkyrien-Skies   Source File: ValkyrienSkiesMod.java    License: 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 20
Source Project: malmo   Source File: MalmoMod.java    License: 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 21
Source Project: malmo   Source File: MalmoMod.java    License: 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 22
Source Project: ExNihiloAdscensio   Source File: ExNihiloAdscensio.java    License: 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 23
Source Project: EnderZoo   Source File: EnderZoo.java    License: 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 24
Source Project: ExNihiloAdscensio   Source File: ExNihiloAdscensio.java    License: 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 25
Source Project: TFC2   Source File: TFC.java    License: 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 26
Source Project: Signals   Source File: Signals.java    License: 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);
}
 
Example 27
Source Project: TinkersToolLeveling   Source File: TinkerToolLeveling.java    License: 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 28
Source Project: ModdingTutorials   Source File: TeleportMod.java    License: 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 29
Source Project: CraftingKeys   Source File: CraftingKeys.java    License: 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 30
Source Project: CraftingKeys   Source File: CraftingKeys.java    License: 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.");

}