Search in sources :

Example 41 with Property

use of net.minecraftforge.common.config.Property in project Railcraft by Railcraft.

the class RailcraftConfig method get.

private static float get(Configuration config, String cat, String tag, float min, float defaultValue, float max, String comment) {
    Property prop = config.get(cat, tag, defaultValue);
    decorateComment(prop, tag, comment);
    double parsed = parseDouble(prop, defaultValue);
    double clamped = Math.max(parsed, min);
    clamped = Math.min(clamped, max);
    if (clamped != parsed)
        prop.set(clamped);
    return (float) clamped;
}
Also used : Property(net.minecraftforge.common.config.Property)

Example 42 with Property

use of net.minecraftforge.common.config.Property in project Railcraft by Railcraft.

the class RailcraftConfig method loadRecipeProperty.

private static void loadRecipeProperty(String subCat, String tag, boolean defaultValue, String comment) {
    Property prop = configMain.get(CAT_RECIPES + "." + subCat, tag, defaultValue);
    decorateComment(prop, tag, comment);
    recipes.put(subCat + "." + tag, prop.getBoolean(defaultValue));
}
Also used : Property(net.minecraftforge.common.config.Property)

Example 43 with Property

use of net.minecraftforge.common.config.Property in project Railcraft by Railcraft.

the class RailcraftConfig method loadBlockProperty.

private static void loadBlockProperty(String tag) {
    cleanOldTags(configBlocks.getCategory(CAT_BLOCKS), tag);
    Property prop = configBlocks.get(CAT_BLOCKS, tag, true);
    enabledBlocks.put(tag, prop.getBoolean(true));
}
Also used : Property(net.minecraftforge.common.config.Property)

Example 44 with Property

use of net.minecraftforge.common.config.Property in project VanillaTeleporter by dyeo.

the class ModConfiguration method preInit.

public static void preInit() {
    File configFile = new File(Loader.instance().getConfigDir(), TeleporterMod.MODID + ".cfg");
    config = new Configuration(configFile);
    config.setCategoryRequiresMcRestart(Configuration.CATEGORY_GENERAL, true);
    config.load();
    config.addCustomCategoryComment(Configuration.CATEGORY_GENERAL, "Vanilla-Inspired Teleporters Version " + TeleporterMod.VERSION + " Configuration");
    Property propUseDiamonds = config.get(Configuration.CATEGORY_GENERAL, "useDiamonds", useDiamonds, "If false, removes diamonds from the crafting recipe and replaces them with quartz blocks.\nDefault is true");
    Property propNumTeleporters = config.get(Configuration.CATEGORY_GENERAL, "numTeleporters", numTeleporters, "Specifies the number of teleporters created with a single recipe.\nDefault is 1");
    Property propTeleportPassiveMobs = config.get(Configuration.CATEGORY_GENERAL, "teleportPassiveMobs", teleportPassiveMobs, "Specifies whether or not passive mobs can go through teleporters.\nDefault is true");
    Property propTeleportHostileMobs = config.get(Configuration.CATEGORY_GENERAL, "teleportHostileMobs", teleportHostileMobs, "Specifies whether or not hostile mobs can go through teleporters.\nDefault is true");
    config.addCustomCategoryComment(ModConfiguration.CATEGORY_SOUNDS, "See http://minecraft.gamepedia.com/Sounds.json#Sound_events for a list of vanilla sound effects");
    Property propSoundEffectTeleporterEnter = config.get(ModConfiguration.CATEGORY_SOUNDS, "soundEffectTeleporterEnter", soundEffectTeleporterEnter, "Sound effect to play when an entity enters a teleporter.\nDefault is \"" + TeleporterMod.MODID + ":portal_enter\", leave blank for no sound.");
    Property propSoundEffectTeleporterExit = config.get(ModConfiguration.CATEGORY_SOUNDS, "soundEffectTeleporterExit", soundEffectTeleporterExit, "Sound effect to play when an entity exits a teleporter.\nDefault is \"" + TeleporterMod.MODID + ":portal_exit\", leave blank for no sound.");
    Property propSoundEffectTeleporterError = config.get(ModConfiguration.CATEGORY_SOUNDS, "soundEffectTeleporterError", soundEffectTeleporterError, "Sound effect to play when a teleporter cannot be used.\nDefault is \"" + TeleporterMod.MODID + ":portal_error\", leave blank for no sound.");
    List<String> propOrderGeneral = new ArrayList<String>();
    propOrderGeneral.add(propUseDiamonds.getName());
    propOrderGeneral.add(propNumTeleporters.getName());
    propOrderGeneral.add(propTeleportPassiveMobs.getName());
    propOrderGeneral.add(propTeleportHostileMobs.getName());
    config.setCategoryPropertyOrder(Configuration.CATEGORY_GENERAL, propOrderGeneral);
    List<String> propOrderSounds = new ArrayList<String>();
    propOrderSounds.add(propSoundEffectTeleporterEnter.getName());
    propOrderSounds.add(propSoundEffectTeleporterExit.getName());
    propOrderSounds.add(propSoundEffectTeleporterError.getName());
    config.setCategoryPropertyOrder(ModConfiguration.CATEGORY_SOUNDS, propOrderSounds);
    useDiamonds = propUseDiamonds.getBoolean();
    numTeleporters = propNumTeleporters.getInt();
    teleportPassiveMobs = propTeleportPassiveMobs.getBoolean();
    teleportHostileMobs = propTeleportHostileMobs.getBoolean();
    soundEffectTeleporterEnter = propSoundEffectTeleporterEnter.getString();
    soundEffectTeleporterExit = propSoundEffectTeleporterExit.getString();
    soundEffectTeleporterError = propSoundEffectTeleporterError.getString();
    if (config.hasChanged())
        config.save();
}
Also used : Configuration(net.minecraftforge.common.config.Configuration) ArrayList(java.util.ArrayList) File(java.io.File) Property(net.minecraftforge.common.config.Property)

Aggregations

Property (net.minecraftforge.common.config.Property)44 ArrayList (java.util.ArrayList)4 File (java.io.File)2 Configuration (net.minecraftforge.common.config.Configuration)2 AMVector2 (am2.api.math.AMVector2)1 IOException (java.io.IOException)1 Date (java.util.Date)1 IRailcraftModule (mods.railcraft.api.core.IRailcraftModule)1 IVariantEnum (mods.railcraft.api.core.IVariantEnum)1 RailcraftModule (mods.railcraft.api.core.RailcraftModule)1 RailcraftBlocks (mods.railcraft.common.blocks.RailcraftBlocks)1 TrackKits (mods.railcraft.common.blocks.tracks.outfitted.TrackKits)1 RailcraftItems (mods.railcraft.common.items.RailcraftItems)1 ItemMap (mods.railcraft.common.util.collections.ItemMap)1 ConfigCategory (net.minecraftforge.common.config.ConfigCategory)1 ModContainer (net.minecraftforge.fml.common.ModContainer)1