Java Code Examples for net.minecraftforge.fml.common.event.FMLPreInitializationEvent#getModConfigurationDirectory()

The following examples show how to use net.minecraftforge.fml.common.event.FMLPreInitializationEvent#getModConfigurationDirectory() . 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: CustomStuff4.java    From customstuff4 with GNU General Public License v3.0 6 votes vote down vote up
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event)
{
    CapabilityItemHandlerSupplier.register();
    MinecraftForge.EVENT_BUS.register(EventHandler.class);

    initPlugins(event.getAsmData());

    File configDir = event.getModConfigurationDirectory();
    File modsDir = new File(configDir.getParent(), "mods");

    registerPackets();

    NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler());
    ModLoader.initMods(modsDir);
}
 
Example 3
Source File: CommonProxy.java    From Logistics-Pipes-2 with MIT License 6 votes vote down vote up
public void preInit(FMLPreInitializationEvent event){
	//Read/make the Config file on Startup
	File directory = event.getModConfigurationDirectory();
	config = new Configuration(new File(directory.getPath(), "LogisticsPipes2.cfg"));
	Config.readConfig();
	
	//Load Blocks
	BlockRegistry.init();
	
	//Load Pipes
	PipeRegistry.init();
	
	//Load Items
	ItemRegistry.init();
	
	TileRegistry.init();
	
	LPPacketHandler.registerMessages();
}
 
Example 4
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 5
Source File: Config.java    From EnderZoo with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
public static void load(FMLPreInitializationEvent event) {
  MinecraftForge.EVENT_BUS.register(new Config());
  configDirectory = new File(event.getModConfigurationDirectory(), EnderZoo.MODID.toLowerCase());
  if (!configDirectory.exists()) {
    configDirectory.mkdir();
  }

  File configFile = new File(configDirectory, "EnderZoo.cfg");
  config = new Configuration(configFile);
  syncConfig();
}
 
Example 6
Source File: Levels.java    From Levels with GNU General Public License v2.0 5 votes vote down vote up
@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
	configDir = new File(event.getModConfigurationDirectory() + "/" + Reference.MODID);
	configDir.mkdirs();
	Config.init(configDir);
	
	ModEvents.register();
	proxy.preInit();
	
	network = NetworkRegistry.INSTANCE.newSimpleChannel(Reference.MODID);
	network.registerMessage(PacketAttributeSelection.Handler.class, PacketAttributeSelection.class, 0, Side.SERVER);
	network.registerMessage(PacketMythicSound.Handler.class, PacketMythicSound.class, 1, Side.CLIENT);
}
 
Example 7
Source File: ForgeMain.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event) {
    this.logger = event.getModLog();
    File directory = new File(event.getModConfigurationDirectory() + File.separator + "FastAsyncWorldEdit");
    MinecraftForge.EVENT_BUS.register(this);
    FMLCommonHandler.instance().bus().register(this);
    this.IMP = new FaweForge(this, event.getModLog(), event.getModMetadata(), directory);
    try {
        Class.forName("org.spongepowered.api.Sponge");
        Settings.IMP.QUEUE.PARALLEL_THREADS = 1;
    } catch (Throwable ignore) {}
}
 
Example 8
Source File: ForgeMain.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event) {
    this.logger = event.getModLog();
    File directory = new File(event.getModConfigurationDirectory() + File.separator + "FastAsyncWorldEdit");
    MinecraftForge.EVENT_BUS.register(this);
    FMLCommonHandler.instance().bus().register(this);
    this.IMP = new FaweForge(this, event.getModLog(), event.getModMetadata(), directory);
    try {
        Class.forName("org.spongepowered.api.Sponge");
        Settings.IMP.QUEUE.PARALLEL_THREADS = 1;
    } catch (Throwable ignore) {}
}
 
Example 9
Source File: ForgeMain.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event) {
    this.logger = event.getModLog();
    File directory = new File(event.getModConfigurationDirectory() + File.separator + "FastAsyncWorldEdit");
    MinecraftForge.EVENT_BUS.register(this);
    FMLCommonHandler.instance().bus().register(this);
    this.IMP = new FaweForge(this, event.getModLog(), event.getModMetadata(), directory);
    try {
        Class.forName("org.spongepowered.api.Sponge");
        Settings.IMP.QUEUE.PARALLEL_THREADS = 1;
    } catch (Throwable ignore) {}
}
 
Example 10
Source File: ForgeMain.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event) {
    this.logger = event.getModLog();
    File directory = new File(event.getModConfigurationDirectory() + File.separator + "FastAsyncWorldEdit");
    MinecraftForge.EVENT_BUS.register(this);
    FMLCommonHandler.instance().bus().register(this);
    this.IMP = new FaweForge(this, event.getModLog(), event.getModMetadata(), directory);
    try {
        Class.forName("org.spongepowered.api.Sponge");
        Settings.IMP.QUEUE.PARALLEL_THREADS = 1;
    } catch (Throwable ignore) {}
}
 
Example 11
Source File: ForgeMain.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event) {
    this.logger = event.getModLog();
    File directory = new File(event.getModConfigurationDirectory() + File.separator + "FastAsyncWorldEdit");
    MinecraftForge.EVENT_BUS.register(this);
    FMLCommonHandler.instance().bus().register(this);
    this.IMP = new FaweForge(this, event.getModLog(), event.getModMetadata(), directory);
    try {
        Class.forName("org.spongepowered.api.Sponge");
        Settings.IMP.QUEUE.PARALLEL_THREADS = 1;
    } catch (Throwable ignore) {}
}
 
Example 12
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 13
Source File: CyberwareConfig.java    From Cyberware with MIT License 5 votes vote down vote up
public static void preInit(FMLPreInitializationEvent event)
{
	configDirectory = event.getModConfigurationDirectory();
	config = new Configuration(new File(event.getModConfigurationDirectory(), Cyberware.MODID + ".cfg"));
	startingItems = defaultStartingItems = new String[EnumSlot.values().length][0];
	startingStacks = new ItemStack[EnumSlot.values().length][LibConstants.WARE_PER_SLOT];
	
	int j = 0;
	for (int i = 0; i < EnumSlot.values().length; i++)
	{
		if (EnumSlot.values()[i].hasEssential())
		{
			if (EnumSlot.values()[i].isSided())
			{
				defaultStartingItems[i] = new String[] { "cyberware:bodyPart 1 " + j, "cyberware:bodyPart 1 " + (j + 1)  };
				j += 2;
			}
			else
			{
				defaultStartingItems[i] = new String[] { "cyberware:bodyPart 1 " + j };
				j++;
			}
		}
		else
		{
			defaultStartingItems[i] = new String[0];
		}
	}
	loadConfig();
	
	config.load();
	for (int index = 0; index < EnumSlot.values().length; index++)
	{
		EnumSlot slot = EnumSlot.values()[index];
		startingItems[index] = config.getStringList("Default augments for " + slot.getName() + " slot",
				"Defaults", defaultStartingItems[index], "Use format 'id amount metadata'");
	}
	config.save();
	
}
 
Example 14
Source File: TraverseConfig.java    From Traverse-Legacy-1-12-2 with MIT License 5 votes vote down vote up
public static void initialize(FMLPreInitializationEvent event) {
	configDir = new File(event.getModConfigurationDirectory(), TraverseConstants.MOD_ID);
	if (!configDir.exists()) {
		configDir.mkdir();
	}

	mainConfig = new File(configDir, "traverse.cfg");
	traverseConfiguration = initialize();
}
 
Example 15
Source File: TraverseConfig.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static void initialize(FMLPreInitializationEvent event) {
	configDir = new File(event.getModConfigurationDirectory(), TraverseConstants.MOD_ID);
	if (!configDir.exists()) {
		configDir.mkdir();
	}

	mainConfig = new File(configDir, "traverse.cfg");
	traverseConfiguration = initialize();
}
 
Example 16
Source File: SkyblockAddons.java    From SkyblockAddons with MIT License 4 votes vote down vote up
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent e) {
    configValues = new ConfigValues(this, e.getSuggestedConfigurationFile());
    persistentValues = new PersistentValues(e.getModConfigurationDirectory());
}
 
Example 17
Source File: MalmoMod.java    From malmo with MIT License 4 votes vote down vote up
@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
     if (!SchemaHelper.testSchemaVersionNumbers(Loader.instance().activeModContainer().getVersion()))
        throw new RuntimeException("This mod has been incorrectly built; check schema version numbers.");

    if (event.getModMetadata().version.equals("${version}"))
    {
        // The mcmod.info version number is populated by gradle; if we've been built without gradle,
        // via eclipse say, then we can just use the internal version number instead, which comes to us from the version.properties file.
        // (There's no real benefit to doing this; it just looks nicer in the Mod GUI if the version number is filled in.)
        event.getModMetadata().version = Loader.instance().activeModContainer().getVersion();
    }
    // Load the correct configs (client or server)
    File configDir = event.getModConfigurationDirectory();
    File sessionConfigFile = new File(configDir, MODID + event.getSide().toString() + ".cfg");
    File permanentConfigFile = new File(configDir, MODID + event.getSide().toString() + "Permanent.cfg");
    this.sessionConfig = new Configuration(sessionConfigFile);
    this.sessionConfig.load();
    this.permanentConfig = new Configuration(permanentConfigFile);
    this.permanentConfig.load();

    AddressHelper.update(this.sessionConfig);
    ScoreHelper.update(this.sessionConfig);
    ScreenHelper.update(this.permanentConfig);
    TCPUtils.update(this.permanentConfig);
    MalmoEnvServer.update(this.sessionConfig);

    network = NetworkRegistry.INSTANCE.newSimpleChannel("Malmo");
    network.registerMessage(ObservationFromFullStatsImplementation.FullStatsRequestMessageHandler.class, ObservationFromFullStatsImplementation.FullStatsRequestMessage.class, 1, Side.SERVER);
    network.registerMessage(ObservationFromGridImplementation.GridRequestMessageHandler.class, ObservationFromGridImplementation.GridRequestMessage.class, 2, Side.SERVER);
    network.registerMessage(MalmoMessageHandler.class, MalmoMessage.class, 3, Side.CLIENT);	// Malmo messages from server to client
    network.registerMessage(SimpleCraftCommandsImplementation.CraftMessageHandler.class, SimpleCraftCommandsImplementation.CraftMessage.class, 4, Side.SERVER);
    network.registerMessage(NearbyCraftCommandsImplementation.CraftNearbyMessageHandler.class, NearbyCraftCommandsImplementation.CraftNearbyMessage.class, 13, Side.SERVER);
    network.registerMessage(NearbySmeltCommandsImplementation.SmeltNearbyMessageHandler.class, NearbySmeltCommandsImplementation.SmeltNearbyMessage.class, 14, Side.SERVER);
    network.registerMessage(AbsoluteMovementCommandsImplementation.TeleportMessageHandler.class, AbsoluteMovementCommandsImplementation.TeleportMessage.class, 5, Side.SERVER);
    network.registerMessage(MalmoMessageHandler.class, MalmoMessage.class, 6, Side.SERVER);	// Malmo messages from client to server
    network.registerMessage(InventoryCommandsImplementation.InventoryMessageHandler.class, InventoryCommandsImplementation.InventoryMessage.class, 7, Side.SERVER);
    network.registerMessage(DiscreteMovementCommandsImplementation.UseActionMessageHandler.class, DiscreteMovementCommandsImplementation.UseActionMessage.class, 8, Side.SERVER);
    network.registerMessage(DiscreteMovementCommandsImplementation.AttackActionMessageHandler.class, DiscreteMovementCommandsImplementation.AttackActionMessage.class, 9, Side.SERVER);
    network.registerMessage(ObservationFromFullInventoryImplementation.InventoryRequestMessageHandler.class, ObservationFromFullInventoryImplementation.InventoryRequestMessage.class, 10, Side.SERVER);
    network.registerMessage(InventoryCommandsImplementation.InventoryChangeMessageHandler.class, InventoryCommandsImplementation.InventoryChangeMessage.class, 11, Side.CLIENT);
    network.registerMessage(ObservationFromSystemImplementation.SystemRequestMessageHandler.class, ObservationFromSystemImplementation.SystemRequestMessage.class, 12, Side.SERVER);
}
 
Example 18
Source File: CommonProxy.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void preInit(FMLPreInitializationEvent event) {
		directory = new File(event.getModConfigurationDirectory(), Wizardry.MODID);
		if (!directory.exists()) if (!directory.mkdirs())
			Wizardry.LOGGER.fatal("    > SOMETHING WENT WRONG! Could not create config folder!!");

		new SpellData.DefaultKeys();

		ManifestUpgrader maniUpgrader = ManifestHandler.INSTANCE.startUpgrade(directory);
		maniUpgrader.changeCategoryName("modules", "wizmodules");
		maniUpgrader.finalizeUpgrade();

		ManifestHandler.INSTANCE.loadNewInternalManifest("wizmodules", "fluid_recipes", "fire_recipes");
		ManifestHandler.INSTANCE.loadExternalManifest(directory);
		ManifestHandler.INSTANCE.processComparisons(directory, "wizmodules", "fluid_recipes", "fire_recipes");

		new ModTab();
		ModBlocks.init();
		ModItems.init();
		ModSounds.init();
		ModPotions.init();
		ModEntities.init();
		ModCapabilities.preInit();

		NetworkRegistry.INSTANCE.registerGuiHandler(Wizardry.instance, new GuiHandler());

		Wizardry.underWorld = DimensionType.register("underworld", "_dim", ConfigValues.underworldID, WorldProviderUnderWorld.class, false);
//		Wizardry.torikki = DimensionType.register("torikki", "_dim", ConfigValues.torikkiID, WorldProviderTorikki.class, false);
		DimensionManager.registerDimension(ConfigValues.underworldID, Wizardry.underWorld);
//		DimensionManager.registerDimension(ConfigValues.torikkiID, Wizardry.torikki);

		MinecraftForge.EVENT_BUS.register(ArenaManager.INSTANCE);
		MinecraftForge.EVENT_BUS.register(new WorldProviderUnderWorld());
		MinecraftForge.EVENT_BUS.register(new EventHandler());
		MinecraftForge.EVENT_BUS.register(new AchievementEvents());
		MinecraftForge.EVENT_BUS.register(new ModuleEffectTimeSlow());
		MinecraftForge.EVENT_BUS.register(new ModuleEffectLeap());
		MinecraftForge.EVENT_BUS.register(ModBiomes.BIOME_UNDERWORLD);
//		MinecraftForge.EVENT_BUS.register(ModBiomes.BIOME_TORIKKI);
//		MinecraftForge.EVENT_BUS.register(ModBiomes.BIOME_TORIKKISEA);
		MinecraftForge.EVENT_BUS.register(this);

		WizardryWorldCapability.init();
		WizardryChunkCapability.init();

		PacketHandler.register(PacketSendSpellToBook.class, Side.SERVER);
		PacketHandler.register(PacketRenderSpell.class, Side.CLIENT);
		PacketHandler.register(PacketExplode.class, Side.CLIENT);
		PacketHandler.register(PacketFreezePlayer.class, Side.CLIENT);
		PacketHandler.register(PacketRenderLightningBolt.class, Side.CLIENT);
		PacketHandler.register(PacketSyncCooldown.class, Side.CLIENT);
		PacketHandler.register(PacketDevilDustFizzle.class, Side.CLIENT);


		PageTypes.INSTANCE.registerPageProvider("wizardry_structure", PageWizardryStructure::new);
		ItemBook.BOOK = new Book("book");

		Wizardry.LOGGER.info("Initializing fairy task plugins...");
		for (final WizardryPlugin plugin : ServiceLoader.load(WizardryPlugin.class)) {
			Wizardry.LOGGER.info("Initializing plugin {}", plugin.getClass().getName());
			plugin.onInit(context);
		}
		Wizardry.LOGGER.info("Initialization complete!");
	}