Search in sources :

Example 6 with Configuration

use of net.minecraftforge.common.config.Configuration in project RFToolsDimensions by McJty.

the class CommonProxy method preInit.

public void preInit(FMLPreInitializationEvent e) {
    GeneralConfig.preInit(e);
    modConfigDir = e.getModConfigurationDirectory();
    mainConfig = new Configuration(new File(modConfigDir.getPath() + File.separator + "rftools", "dimensions.cfg"));
    readMainConfig();
    SimpleNetworkWrapper network = PacketHandler.registerMessages(RFToolsDim.MODID, "rftoolsdim");
    RFToolsDimMessages.registerNetworkMessages(network);
    ModItems.init();
    ModBlocks.init();
    ModDimensions.init();
    DimletRules.readRules(modConfigDir);
}
Also used : SimpleNetworkWrapper(net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper) Configuration(net.minecraftforge.common.config.Configuration) File(java.io.File)

Example 7 with Configuration

use of net.minecraftforge.common.config.Configuration in project RFToolsDimensions by McJty.

the class CommonProxy method readMainConfig.

private void readMainConfig() {
    Configuration cfg = mainConfig;
    try {
        cfg.load();
        cfg.addCustomCategoryComment(GeneralConfiguration.CATEGORY_GENERAL, "Dimension related settings");
        cfg.addCustomCategoryComment(MachineConfiguration.CATEGORY_MACHINES, "Machine related settings");
        cfg.addCustomCategoryComment(WorldgenConfiguration.CATEGORY_WORLDGEN, "Worldgen related settings");
        cfg.addCustomCategoryComment(PowerConfiguration.CATEGORY_POWER, "Power related settings");
        cfg.addCustomCategoryComment(DimletConfiguration.CATEGORY_DIMLETS, "Dimlet related settings");
        cfg.addCustomCategoryComment(MobConfiguration.CATEGORY_MOBS, "Mob related settings");
        cfg.addCustomCategoryComment(OresAPlentyConfiguration.CATEGORY_ORESAPLENTY, "Settings for the OresAPlenty dimlet");
        cfg.addCustomCategoryComment(DimletConstructionConfiguration.CATEGORY_DIMLET_CONSTRUCTION, "Dimlet construction related settings");
        cfg.addCustomCategoryComment(LostCityConfiguration.CATEGORY_LOSTCITY, "Settings related to the Lost City dimlet");
        GeneralConfiguration.init(cfg);
        MachineConfiguration.init(cfg);
        WorldgenConfiguration.init(cfg);
        PowerConfiguration.init(cfg);
        DimletConfiguration.init(cfg);
        MobConfiguration.init(cfg);
        OresAPlentyConfiguration.init(cfg);
        LostCityConfiguration.init(cfg);
        DimletConstructionConfiguration.init(cfg);
    } catch (Exception e1) {
        FMLLog.log(Level.ERROR, e1, "Problem loading config file!");
    } finally {
        if (mainConfig.hasChanged()) {
            mainConfig.save();
        }
    }
}
Also used : Configuration(net.minecraftforge.common.config.Configuration)

Example 8 with Configuration

use of net.minecraftforge.common.config.Configuration in project OpenLights by PC-Logix.

the class OpenLights method preInit.

@EventHandler
public void preInit(FMLPreInitializationEvent event) {
    cfg = new Config(new Configuration(event.getSuggestedConfigurationFile()));
    if ((event.getSourceFile().getName().endsWith(".jar") || debug) && event.getSide().isClient() && cfg.enableMUD) {
        try {
            Class.forName("pcl.openprinter.mud.ModUpdateDetector").getDeclaredMethod("registerMod", ModContainer.class, URL.class, URL.class).invoke(null, FMLCommonHandler.instance().findContainerFor(this), new URL("http://PC-Logix.com/OpenLights/get_latest_build.php"), new URL("http://PC-Logix.com/OpenLights/changelog.txt"));
        } catch (Throwable e) {
        //e.printStackTrace();
        }
    }
    //GameRegistry.registerBlock(openLightBlock, "openlights.openlight");
    GameRegistry.registerBlock(openLightBlock, MultiItemBlock.class, "openlights.openlight");
    for (int ix = 0; ix < 16; ix++) {
        ItemStack multiBlockStack = new ItemStack(openLightBlock, 1, ix);
    }
    GameRegistry.registerTileEntity(OpenLightTE.class, "OpenLightTE");
    //openLightBlock.setCreativeTab(li.cil.oc.api.CreativeTab.instance);
    prismaticPaste = new PrismaticPaste();
    GameRegistry.registerItem(prismaticPaste, "openlights.prismaticPaste");
}
Also used : Configuration(net.minecraftforge.common.config.Configuration) ModContainer(cpw.mods.fml.common.ModContainer) PrismaticPaste(pcl.openlights.items.PrismaticPaste) ItemStack(net.minecraft.item.ItemStack) URL(java.net.URL) EventHandler(cpw.mods.fml.common.Mod.EventHandler)

Example 9 with Configuration

use of net.minecraftforge.common.config.Configuration in project Realistic-Terrain-Generation by Team-RTG.

the class Config method load.

public void load(String configFile) {
    Configuration config = new Configuration(new File(configFile));
    try {
        config.load();
        ArrayList<ConfigProperty> properties = this.getProperties();
        for (int j = 0; j < properties.size(); j++) {
            ConfigProperty prop = properties.get(j);
            switch(prop.type) {
                case INTEGER:
                    ConfigPropertyInt propInt = (ConfigPropertyInt) properties.get(j);
                    propInt.set(config.getInt(propInt.name, propInt.category, propInt.valueInt, propInt.minValueInt, propInt.maxValueInt, prop.description));
                    break;
                case FLOAT:
                    ConfigPropertyFloat propFloat = (ConfigPropertyFloat) properties.get(j);
                    propFloat.set(config.getFloat(propFloat.name, propFloat.category, propFloat.valueFloat, propFloat.minValueFloat, propFloat.maxValueFloat, propFloat.description));
                    break;
                case BOOLEAN:
                    ConfigPropertyBoolean propBool = (ConfigPropertyBoolean) properties.get(j);
                    propBool.set(config.getBoolean(propBool.name, propBool.category, propBool.valueBoolean, propBool.description));
                    break;
                case STRING:
                    ConfigPropertyString propString = (ConfigPropertyString) properties.get(j);
                    propString.set(config.getString(propString.name, propString.category, propString.valueString, propString.description));
                    break;
                default:
                    throw new RuntimeException("ConfigProperty type not supported.");
            }
        }
    } catch (Exception e) {
        FMLLog.log(Level.ERROR, "[RTG-ERROR] RTG had a problem loading config: %s", configFile);
    } finally {
        if (config.hasChanged()) {
            config.save();
        }
    }
}
Also used : Configuration(net.minecraftforge.common.config.Configuration) File(java.io.File)

Example 10 with Configuration

use of net.minecraftforge.common.config.Configuration in project Guide-API by TeamAmeriFrance.

the class ConfigHandler method init.

public static void init(File file) {
    config = new Configuration(file);
    syncConfig();
}
Also used : Configuration(net.minecraftforge.common.config.Configuration)

Aggregations

Configuration (net.minecraftforge.common.config.Configuration)35 File (java.io.File)14 EventHandler (cpw.mods.fml.common.Mod.EventHandler)4 EventHandler (net.minecraftforge.fml.common.Mod.EventHandler)4 IOException (java.io.IOException)2 Property (net.minecraftforge.common.config.Property)2 AgriConfigAdapter (com.agricraft.agricore.config.AgriConfigAdapter)1 WorldConversionEventHandler (com.bluepowermod.convert.WorldConversionEventHandler)1 BPEventHandler (com.bluepowermod.event.BPEventHandler)1 Config (com.bluepowermod.init.Config)1 RedstoneProviderQmunityLib (com.bluepowermod.redstone.RedstoneProviderQmunityLib)1 ProxyASMTest (com.builtbroken.mc.core.asm.ProxyASMTest)1 ItemDevData (com.builtbroken.mc.core.content.debug.ItemDevData)1 ItemInstaHole (com.builtbroken.mc.core.content.debug.ItemInstaHole)1 TileInfInv (com.builtbroken.mc.core.content.debug.TileInfInv)1 ItemScrewdriver (com.builtbroken.mc.core.content.tool.ItemScrewdriver)1 ItemSelectionWand (com.builtbroken.mc.core.content.tool.ItemSelectionWand)1 ToolModeGeneral (com.builtbroken.mc.core.content.tool.screwdriver.ToolModeGeneral)1 ToolModeRotation (com.builtbroken.mc.core.content.tool.screwdriver.ToolModeRotation)1 DevWorldLoader (com.builtbroken.mc.core.content.world.DevWorldLoader)1