Java Code Examples for net.minecraftforge.common.config.Configuration#getCategory()

The following examples show how to use net.minecraftforge.common.config.Configuration#getCategory() . 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: ConfigGuiFactory.java    From OpenPeripheral with MIT License 5 votes vote down vote up
private static IConfigElement createModConfig() {
	final Configuration config = OpenPeripheralCore.instance.config();
	final List<IConfigElement> result = Lists.newArrayList();

	for (String categoryName : config.getCategoryNames()) {
		if (!categoryName.equalsIgnoreCase(Config.CATEGORY_FEATURE_GROUPS)) {
			ConfigCategory category = config.getCategory(categoryName);
			result.add(new ConfigElement(category));
		}
	}

	return new DummyCategoryElement("modConfig", "openperipheralcore.config.miscConfig", result);
}
 
Example 2
Source File: OpenPeripheralIntegration.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@EventHandler
public void preInit(FMLPreInitializationEvent evt) {
	config = new Configuration(evt.getSuggestedConfigurationFile());

	if (config.hasCategory("integration")) {
		ConfigCategory integration = config.getCategory("integration");
		config.removeCategory(integration);
	}

	if (checkConfig(config, "vanilla")) Integration.addModule(new ModuleVanilla());
	if (checkConfig(config, "vanilla-inventory")) Integration.addModule(new ModuleVanillaInventory());
	if (checkConfig(config, "vanilla-inventory-manipulation")) Integration.addModule(new ModuleVanillaInventoryManipulation());

	if (checkConfig(config, "cofh-api-energy")) Integration.addModule(new ModuleCofhEnergy());
	if (checkConfig(config, "cofh-api-inventory")) Integration.addModule(new ModuleCofhInventory());
	if (checkConfig(config, "cofh-api-item")) Integration.addModule(new ModuleCofhItem());
	if (checkConfig(config, "cofh-api-tileentity")) Integration.addModule(new ModuleCofhTileEntity());
	if (checkConfig(config, "cofh-api-transport")) Integration.addModule(new ModuleCofhTransport());

	if (checkConfig(config, "buildcraft-api-transport")) Integration.addModule(new ModuleBuildCraftTransport());
	if (checkConfig(config, "buildcraft-api-tilenentity")) Integration.addModule(new ModuleBuildCraftTile());
	if (checkConfig(config, "buildcraft-api-facades")) Integration.addModule(new ModuleBuildCraftFacades());

	if (checkConfig(config, "ic2-mod")) Integration.addModule(new ModuleIC2());
	if (checkConfig(config, "ic2-api")) Integration.addModule(new ModuleIC2Api());

	if (checkConfig(config, "railcraft-mod")) Integration.addModule(new ModuleRailcraft());
	if (checkConfig(config, "railcraft-api-carts")) Integration.addModule(new ModuleRailcraftCarts());
	if (checkConfig(config, "railcraft-api-fuel")) Integration.addModule(new ModuleRailcraftFuel());

	if (checkConfig(config, "thaumcraft-mod")) Integration.addModule(new ModuleThaumcraft());
	if (checkConfig(config, "thaumcraft-api")) Integration.addModule(new ModuleThaumcraftApi());

	if (checkConfig(config, "mfr-mod")) Integration.addModule(new ModuleMinefactoryReloaded());
	if (checkConfig(config, "mfr-mod-storage")) Integration.addModule(new ModuleMinefactoryReloadedStorage());

	if (checkConfig(config, "computercraft-mod")) Integration.addModule(new ModuleComputerCraft());
	if (checkConfig(config, "enderstorage-mod")) Integration.addModule(new ModuleEnderStorage());
	if (checkConfig(config, "forestry-mod")) Integration.addModule(new ModuleForestry());
	if (checkConfig(config, "mystcraft-mod")) {
		if (sameOrNewerVersion(Mods.MYSTCRAFT, "0.11.1.00")) {
			if (sameOrNewerVersion(Mods.MYSTCRAFT, "0.11.6.02")) {
				FMLInterModComms.sendMessage(Mods.MYSTCRAFT, "API", "openperipheral.integration.mystcraft.v2.MystcraftAccess.init");
				Integration.addModule(new ModuleMystcraftV2());
			} else {
				Log.warn("Unsupported Mystcraft version!");
			}
		} else {
			Log.warn("Using old Mystcraft integration, things may explode");
			Integration.addModule(new ModuleMystcraftV1());
		}
	}
	if (checkConfig(config, "thaumcraft-mod")) Integration.addModule(new ModuleThaumcraft());
	if (checkConfig(config, "tmechworks-mod")) Integration.addModule(new ModuleTMechworks());
	if (checkConfig(config, "thermalexpansion-mod")) Integration.addModule(new ModuleThermalExpansion());
	if (checkConfig(config, "ae2-mod")) Integration.addModule(new ModuleAppEng());

	ConfigProcessing.processAnnotations(MOD_ID, config, Config.class);

	FMLCommonHandler.instance().bus().register(new ConfigChangeListener(MOD_ID, config));

	if (config.hasChanged()) config.save();
}
 
Example 3
Source File: ConfigManager.java    From GardenCollection with MIT License 4 votes vote down vote up
public ConfigManager (File file) {
    config = new Configuration(file);

    Property propEnableVillagerTrading = config.get(Configuration.CATEGORY_GENERAL, "enableVillagerStampTrading", true);
    propEnableVillagerTrading.comment = "Allows some villagers to buy and sell pattern stamps.";
    enableVillagerTrading = propEnableVillagerTrading.getBoolean();

    boolean firstGen = !config.hasCategory(CAT_PATTERNS);

    categoryPatterns = config.getCategory(CAT_PATTERNS);
    categoryPatterns.setComment("Patterns are additional textures that can be overlaid on top of large pots, both normal and colored.\n"
        + "For each pattern defined, a corresponding 'stamp' item is registered.  The stamp is used with the\n"
        + "pottery table to apply patterns to raw clay pots.\n\n"
        + "This mod can support up to 255 registered patterns.  To add a new pattern, create a new entry in the\n"
        + "config below using the form:\n\n"
        + "  S:pattern.#=texture_name; A Name\n\n"
        + "Where # is an id between 1 and 255 inclusive.\n"
        + "Place a corresponding texture_name.png file into the mod's jar file in assets/modularpots/textures/blocks.\n"
        + "To further control aspects of the pattern, seeing the next section, pattern_settings.\n\n"
        + "Note: Future versions of this mod may add new patterns.  If you haven't made any changes to this\n"
        + "configuration, simply delete it and let it regenerate.  Otherwise visit the mod's development thread\n"
        + "on Minecraft Forums to see what's changed.");

    categoryPatternSettings = config.getCategory(CAT_SETTINGS);
    categoryPatternSettings.setComment("Specifies all the attributes for patterns.  Attributes control how patterns can be found in the world.\n"
        + "In the future, they might control other aspects, such as how patterns are rendered.\n\n"
        + "By default, all patterns will take their attributes from the 'pattern_default' subcategory.  To\n"
        + "customize some or all attributes for a pattern, create a new subcategory modeled like this:\n\n"
        + "  pattern_# {\n"
        + "      I:weight=5\n"
        + "  }\n\n"
        + "The S:pattern_gen option controls what kinds of dungeon chests the pattern's stamp item will appear in, and the\n"
        + "rarity of the item appearing.  The location and rarity are separated by a comma (,), and multiple locations\n"
        + "are separated with a semicolon (;).  Rarity is a value between 1 and 100, with 1 being very rare.  Golden\n"
        + "apples and diamond horse armor also have a rarity of 1.  Most vanilla items have a rarity of 10.  The valid\n"
        + "location strings are:\n\n"
        + "  mineshaftCorridor, pyramidDesertChest, pyramidJungleChest, strongholdCorridor, strongholdLibrary,\n"
        + "  strongholdCrossing, villageBlacksmith, dungeonChest");

    populateDefaultPattern();

    if (firstGen) {
        config.get(categoryPatterns.getQualifiedName(), "pattern.1", "large_pot_1; Serpent");
        config.get(categoryPatterns.getQualifiedName(), "pattern.2", "large_pot_2; Lattice");
        config.get(categoryPatterns.getQualifiedName(), "pattern.3", "large_pot_3; Offset Squares");
        config.get(categoryPatterns.getQualifiedName(), "pattern.4", "large_pot_4; Inset");
        config.get(categoryPatterns.getQualifiedName(), "pattern.5", "large_pot_5; Turtle");
        config.get(categoryPatterns.getQualifiedName(), "pattern.6", "large_pot_6; Creeper");
        config.get(categoryPatterns.getQualifiedName(), "pattern.7", "large_pot_7; Freewheel");
        config.get(categoryPatterns.getQualifiedName(), "pattern.8", "large_pot_8; Creepy Castle");
        config.get(categoryPatterns.getQualifiedName(), "pattern.9", "large_pot_9; Savannah");
        config.get(categoryPatterns.getQualifiedName(), "pattern.10", "large_pot_10; Scales");
        config.get(categoryPatterns.getQualifiedName(), "pattern.11", "large_pot_11; Growth");
        config.get(categoryPatterns.getQualifiedName(), "pattern.12", "large_pot_12; Fern");
        config.get(categoryPatterns.getQualifiedName(), "pattern.13", "large_pot_13; Diamond");

        config.getCategory(CAT_SETTINGS + ".pattern_2");
        config.get(CAT_SETTINGS + ".pattern_2", "weight", 8);
    }

    config.save();

    for (int i = 1; i < 256; i++) {
        if (config.hasKey(categoryPatterns.getQualifiedName(), "pattern." + i)) {
            String entry = config.get(categoryPatterns.getQualifiedName(), "pattern." + i, "").getString();
            String[] parts = entry.split("[ ]*;[ ]*");

            String overlay = parts[0];
            String name = (parts.length > 1) ? parts[1] : null;

            patterns[i] = new PatternConfig(i, overlay, name);
            if (config.hasCategory(CAT_SETTINGS + ".pattern_" + i))
                parsePatternAttribs(patterns[i], CAT_SETTINGS + ".pattern_" + i);
            else {
                if (patterns[i].getName() == null)
                    patterns[i].setName(defaultPattern.getName());

                patterns[i].setWeight(defaultPattern.getWeight());
            }

            patternCount++;
        }
    }
}
 
Example 4
Source File: GuiConfigSimple.java    From LunatriusCore with MIT License 4 votes vote down vote up
private static List<IConfigElement> getConfigElements(final Configuration configuration, final String categoryName) {
    final ConfigElement element = new ConfigElement(configuration.getCategory(categoryName));
    return element.getChildElements();
}