Java Code Examples for net.minecraftforge.common.config.Property#getDouble()

The following examples show how to use net.minecraftforge.common.config.Property#getDouble() . 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: TFCOptions.java    From TFC2 with GNU General Public License v3.0 6 votes vote down vote up
public static double getDoubleFor(Configuration config,String heading, String item, double value, String comment)
{
	if (config == null)
		return value;
	try
	{
		Property prop = config.get(heading, item, value);
		prop.setComment(comment);
		return prop.getDouble(value);
	}
	catch (Exception e)
	{
		System.out.println("[TFC2] Error while trying to add Double, config wasn't loaded properly!");
	}
	return value;
}
 
Example 2
Source File: ConfigManager.java    From GardenCollection with MIT License 6 votes vote down vote up
public ConfigManager (File file) {
    config = new Configuration(file);

    Property propEnableCompostBonemeal = config.get(Configuration.CATEGORY_GENERAL, "enableCompostBonemeal", true);
    propEnableCompostBonemeal.comment = "Allows compost trigger plant growth like bonemeal.";
    enableCompostBonemeal = propEnableCompostBonemeal.getBoolean();

    Property propCompostBonemealStrength = config.get(Configuration.CATEGORY_GENERAL, "compostBonemealStrength", 0.5);
    propCompostBonemealStrength.comment = "The probability that compost will succeed when used as bonemeal relative to bonemeal.";
    compostBonemealStrength = propCompostBonemealStrength.getDouble();

    Property propEnableTilledSoilGrowthBonus = config.get(Configuration.CATEGORY_GENERAL, "enableTilledSoilGrowthBonus", true).setRequiresMcRestart(true);
    propEnableTilledSoilGrowthBonus.comment = "Allows tilled garden soil to advance crop growth more quickly.  Enables random ticks.";
    enableTilledSoilGrowthBonus = propEnableTilledSoilGrowthBonus.getBoolean();

    config.save();
}
 
Example 3
Source File: Config.java    From Levels with GNU General Public License v2.0 5 votes vote down vote up
private static void syncMain()
{
	String category = "main";
	List<String> propOrder = Lists.newArrayList();
	Property prop;
	
	/*
	 * Experience
	 */
	prop = main.get(category, "maxLevel", maxLevel);
	prop.setComment("Determines the max level of weapons and armor.");
	maxLevel = prop.getDouble();
	propOrder.add(prop.getName());
	
	prop = main.get(category, "experienceExponent", expExponent);
	prop.setComment("Sets the exponent of the experience algorithm.");
	expExponent = prop.getDouble();
	propOrder.add(prop.getName());
	
	prop = main.get(category, "experienceMultiplier", expMultiplier);
	prop.setComment("Sets the multiplier of the experience algorithm.");
	expMultiplier = prop.getInt();
	propOrder.add(prop.getName());
	
	/*
	 * Miscellaneous
	 */
	prop = main.get(category, "itemBlacklist", itemBlacklist);
	prop.setComment("Items in this blacklist will not gain the leveling systems. Useful for very powerful items or potential conflicts. Style should be 'modid:item'");
	itemBlacklist = prop.getStringList();
	propOrder.add(prop.getName());
	
	prop = main.get(category, "unlimitedDurability", unlimitedDurability);
	prop.setComment("Determines whether or not weapons and armor will lose durability.");
	unlimitedDurability = prop.getBoolean();
	propOrder.add(prop.getName());
	
	main.setCategoryPropertyOrder(category, propOrder);
	main.save();
}
 
Example 4
Source File: ConfigManager.java    From GardenCollection with MIT License 5 votes vote down vote up
public ConfigManager (File file) {
    config = new Configuration(file);

    Property propStrangePlantDrops = config.get(Configuration.CATEGORY_GENERAL, "strangePlantDrops", new String[0]);
    propStrangePlantDrops.comment = "A list of zero or more item IDs.  Breaking the plant will drop an item picked at random from the list.  Ex: minecraft:coal:1";

    Property propStrangePlantDropChance = config.get(Configuration.CATEGORY_GENERAL, "strangePlantDropChance", 1.0);
    propStrangePlantDropChance.comment = "The probability from 0.0 - 1.0 that breaking a strange plant will drop its contents.";
    strangePlantDropChance = propStrangePlantDropChance.getDouble();

    Property propStrangePlantDropMin = config.get(Configuration.CATEGORY_GENERAL, "strangePlantDropMin", 1);
    propStrangePlantDropMin.comment = "The minimum number of items dropped when breaking a strange plant.";
    strangePlantDropMin = propStrangePlantDropMin.getInt();

    Property propStrangePlantDropMax = config.get(Configuration.CATEGORY_GENERAL, "strangePlantDropMax", 1);
    propStrangePlantDropMax.comment = "The maximum number of items dropped when breaking a strange plant.";
    strangePlantDropMax = propStrangePlantDropMax.getInt();

    Property propCompostGrowsOrnamentalTrees = config.get(Configuration.CATEGORY_GENERAL, "compostGrowsOrnamentalTrees", true);
    propCompostGrowsOrnamentalTrees.comment = "Using compost on saplings will grow ornamental (miniature) trees instead of normal trees.";
    compostGrowsOrnamentalTrees = propCompostGrowsOrnamentalTrees.getBoolean();

    Property propGenerateCandelilla = config.get(Configuration.CATEGORY_GENERAL, "generateCandelilla", true);
    propGenerateCandelilla.comment = "Generates clusters of candelilla shrub in warm, sandy biomes.";
    generateCandelilla = propGenerateCandelilla.getBoolean();

    config.save();
}
 
Example 5
Source File: Settings.java    From MediaMod with GNU General Public License v3.0 4 votes vote down vote up
private static void updateConfig(Configuration configuration, boolean load) {
    Property enabledProperty = configuration.get("General", "enabled", true);
    Property showPlayerProperty = configuration.get("General", "showPlayer", true);
    Property modernPlayerProperty = configuration.get("Player", "modernPlayer", true);
    Property albumArtProperty = configuration.get("Player", "showAlbumArt", true);
    Property autoColorProperty = configuration.get("Player", "automaticColorSelection", true);
    Property saveSpotifyTokenProperty = configuration.get("General", "saveSpotifyToken", true);
    Property announceTracksProperty = configuration.get("Player", "announceTracks", true);
    Property playerXProperty = configuration.get("Player", "playerX", 5.0);
    Property playerYProperty = configuration.get("Player", "playerY", 5.0);
    Property playerZoomProperty = configuration.get("Player", "playerZoom", 1.0);
    Property browserExtProperty = configuration.get("Player", "useBrowserExtension", true);
    Property progressStyleProperty = configuration.get("Player", "progressStyle", ProgressStyle.BAR_AND_NUMBERS_NEW.name());
    Property refreshTokenProperty = configuration.get("Spotify", "refreshToken", "");

    if (load) SAVE_SPOTIFY_TOKEN = saveSpotifyTokenProperty.getBoolean();
    else saveSpotifyTokenProperty.setValue(SAVE_SPOTIFY_TOKEN);

    if (load) REFRESH_TOKEN = refreshTokenProperty.getString();
    else {
        if(SAVE_SPOTIFY_TOKEN) {
            refreshTokenProperty.setValue(REFRESH_TOKEN);
        } else {
            refreshTokenProperty.setValue("");
        }
    }

    if (load) ENABLED = enabledProperty.getBoolean();
    else enabledProperty.setValue(ENABLED);

    if (load) ANNOUNCE_TRACKS = announceTracksProperty.getBoolean();
    else announceTracksProperty.setValue(ANNOUNCE_TRACKS);

    if (load) PROGRESS_STYLE = ProgressStyle.valueOf(progressStyleProperty.getString());
    else progressStyleProperty.setValue(PROGRESS_STYLE.name());

    if (load) SHOW_PLAYER = showPlayerProperty.getBoolean();
    else showPlayerProperty.setValue(SHOW_PLAYER);

    if (load) MODERN_PLAYER_STYLE = modernPlayerProperty.getBoolean();
    else modernPlayerProperty.setValue(MODERN_PLAYER_STYLE);

    if (load) SHOW_ALBUM_ART = albumArtProperty.getBoolean();
    else albumArtProperty.setValue(SHOW_ALBUM_ART);

    if (load) AUTO_COLOR_SELECTION = autoColorProperty.getBoolean();
    else autoColorProperty.setValue(AUTO_COLOR_SELECTION);

    if (load) PLAYER_X = playerXProperty.getDouble();
    else playerXProperty.setValue(PLAYER_X);

    if (load) PLAYER_Y = playerYProperty.getDouble();
    else playerYProperty.setValue(PLAYER_Y);

    if (load) PLAYER_ZOOM = playerZoomProperty.getDouble();
    else playerZoomProperty.setValue(PLAYER_ZOOM);

    if (load) EXTENSION_ENABLED = browserExtProperty.getBoolean();
    else browserExtProperty.setValue(EXTENSION_ENABLED);
}