Search in sources :

Example 1 with Property

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

the class ForgeModContainer method syncConfig.

/**
     * Synchronizes the local fields with the values in the Configuration object.
     */
private static void syncConfig(boolean load) {
    // By adding a property order list we are defining the order that the properties will appear both in the config file and on the GUIs.
    // Property order lists are defined per-ConfigCategory.
    List<String> propOrder = new ArrayList<String>();
    if (!config.isChild) {
        if (load) {
            config.load();
        }
        Property enableGlobalCfg = config.get(Configuration.CATEGORY_GENERAL, "enableGlobalConfig", false).setShowInGui(false);
        if (enableGlobalCfg.getBoolean(false)) {
            Configuration.enableGlobalConfig();
        }
    }
    Property prop;
    // clean up old properties that are not used anymore
    if (config.getCategory(CATEGORY_GENERAL).containsKey("defaultSpawnFuzz"))
        config.getCategory(CATEGORY_GENERAL).remove("defaultSpawnFuzz");
    if (config.getCategory(CATEGORY_GENERAL).containsKey("spawnHasFuzz"))
        config.getCategory(CATEGORY_GENERAL).remove("spawnHasFuzz");
    if (config.getCategory(CATEGORY_GENERAL).containsKey("disableStitchedFileSaving"))
        config.getCategory(CATEGORY_GENERAL).remove("disableStitchedFileSaving");
    prop = config.get(CATEGORY_GENERAL, "disableVersionCheck", false);
    prop.setComment("Set to true to disable Forge's version check mechanics. Forge queries a small json file on our server for version information. For more details see the ForgeVersion class in our github.");
    // Language keys are a good idea to implement if you are using config GUIs. This allows you to use a .lang file that will hold the
    // "pretty" version of the property name as well as allow others to provide their own localizations.
    // This language key is also used to get the tooltip for a property. The tooltip language key is langKey + ".tooltip".
    // If no tooltip language key is defined in your .lang file, the tooltip will default to the property comment field.
    prop.setLanguageKey("forge.configgui.disableVersionCheck");
    disableVersionCheck = prop.getBoolean(disableVersionCheck);
    propOrder.add(prop.getName());
    prop = config.get(Configuration.CATEGORY_GENERAL, "clumpingThreshold", 64, "Controls the number threshold at which Packet51 is preferred over Packet52, default and minimum 64, maximum 1024", 64, 1024);
    prop.setLanguageKey("forge.configgui.clumpingThreshold").setRequiresWorldRestart(true);
    clumpingThreshold = prop.getInt(64);
    if (clumpingThreshold > 1024 || clumpingThreshold < 64) {
        clumpingThreshold = 64;
        prop.set(64);
    }
    propOrder.add(prop.getName());
    prop = config.get(CATEGORY_GENERAL, "sortRecipies", true);
    prop.setComment("Set to true to enable the post initialization sorting of crafting recipes using Forge's sorter. May cause desyncing on conflicting recipes. MUST RESTART MINECRAFT IF CHANGED FROM THE CONFIG GUI.");
    prop.setLanguageKey("forge.configgui.sortRecipies").setRequiresMcRestart(true);
    shouldSortRecipies = prop.getBoolean(true);
    propOrder.add(prop.getName());
    prop = config.get(Configuration.CATEGORY_GENERAL, "removeErroringEntities", false);
    prop.setComment("Set this to true to remove any Entity that throws an error in its update method instead of closing the server and reporting a crash log. BE WARNED THIS COULD SCREW UP EVERYTHING USE SPARINGLY WE ARE NOT RESPONSIBLE FOR DAMAGES.");
    prop.setLanguageKey("forge.configgui.removeErroringEntities").setRequiresWorldRestart(true);
    removeErroringEntities = prop.getBoolean(false);
    propOrder.add(prop.getName());
    if (removeErroringEntities) {
        FMLLog.warning("Enabling removal of erroring Entities - USE AT YOUR OWN RISK");
    }
    prop = config.get(Configuration.CATEGORY_GENERAL, "removeErroringTileEntities", false);
    prop.setComment("Set this to true to remove any TileEntity that throws an error in its update method instead of closing the server and reporting a crash log. BE WARNED THIS COULD SCREW UP EVERYTHING USE SPARINGLY WE ARE NOT RESPONSIBLE FOR DAMAGES.");
    prop.setLanguageKey("forge.configgui.removeErroringTileEntities").setRequiresWorldRestart(true);
    removeErroringTileEntities = prop.getBoolean(false);
    propOrder.add(prop.getName());
    if (removeErroringTileEntities) {
        FMLLog.warning("Enabling removal of erroring Tile Entities - USE AT YOUR OWN RISK");
    }
    prop = config.get(Configuration.CATEGORY_GENERAL, "fullBoundingBoxLadders", false);
    prop.setComment("Set this to true to check the entire entity's collision bounding box for ladders instead of just the block they are in. Causes noticeable differences in mechanics so default is vanilla behavior. Default: false");
    prop.setLanguageKey("forge.configgui.fullBoundingBoxLadders").setRequiresWorldRestart(true);
    fullBoundingBoxLadders = prop.getBoolean(false);
    propOrder.add(prop.getName());
    prop = config.get(Configuration.CATEGORY_GENERAL, "biomeSkyBlendRange", new int[] { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34 });
    prop.setComment("Control the range of sky blending for colored skies in biomes.");
    prop.setLanguageKey("forge.configgui.biomeSkyBlendRange");
    blendRanges = prop.getIntList();
    propOrder.add(prop.getName());
    prop = config.get(Configuration.CATEGORY_GENERAL, "zombieBaseSummonChance", 0.1, "Base zombie summoning spawn chance. Allows changing the bonus zombie summoning mechanic.", 0.0D, 1.0D);
    prop.setLanguageKey("forge.configgui.zombieBaseSummonChance").setRequiresWorldRestart(true);
    zombieSummonBaseChance = prop.getDouble(0.1);
    propOrder.add(prop.getName());
    prop = config.get(Configuration.CATEGORY_GENERAL, "zombieBabyChance", 0.05, "Chance that a zombie (or subclass) is a baby. Allows changing the zombie spawning mechanic.", 0.0D, 1.0D);
    prop.setLanguageKey("forge.configgui.zombieBabyChance").setRequiresWorldRestart(true);
    zombieBabyChance = (float) prop.getDouble(0.05);
    propOrder.add(prop.getName());
    prop = config.get(Configuration.CATEGORY_GENERAL, "forgeLightPipelineEnabled", true, "Enable the forge block rendering pipeline - fixes the lighting of custom models.");
    forgeLightPipelineEnabled = prop.getBoolean(true);
    prop.setLanguageKey("forge.configgui.forgeLightPipelineEnabled");
    propOrder.add(prop.getName());
    prop = config.get(Configuration.CATEGORY_GENERAL, "logCascadingWorldGeneration", true, "Log cascading chunk generation issues during terrain population.");
    logCascadingWorldGeneration = prop.getBoolean();
    prop.setLanguageKey("forge.configgui.logCascadingWorldGeneration");
    propOrder.add(prop.getName());
    config.setCategoryPropertyOrder(CATEGORY_GENERAL, propOrder);
    propOrder = new ArrayList<String>();
    prop = config.get(VERSION_CHECK_CAT, "Global", true, "Enable the entire mod update check system. This only applies to mods using the Forge system.");
    propOrder.add("Global");
    config.setCategoryPropertyOrder(VERSION_CHECK_CAT, propOrder);
    // Client-Side only properties
    propOrder = new ArrayList<String>();
    prop = config.get(Configuration.CATEGORY_CLIENT, "replaceVanillaBucketModel", false, "Replace the vanilla bucket models with Forges own dynamic bucket model. Unifies bucket visuals if a mod uses the Forge bucket model.");
    prop.setLanguageKey("forge.configgui.replaceBuckets").setRequiresMcRestart(true);
    replaceVanillaBucketModel = prop.getBoolean(false);
    propOrder.add(prop.getName());
    prop = config.get(Configuration.CATEGORY_CLIENT, "zoomInMissingModelTextInGui", false, "Toggle off to make missing model text in the gui fit inside the slot.");
    zoomInMissingModelTextInGui = prop.getBoolean(false);
    prop.setLanguageKey("forge.configgui.zoomInMissingModelTextInGui");
    propOrder.add(prop.getName());
    prop = config.get(Configuration.CATEGORY_CLIENT, "java8Reminder", 0, "The timestamp of the last reminder to update to Java 8 in number of milliseconds since January 1, 1970, 00:00:00 GMT. Nag will show only once every 24 hours. To disable it set this to some really high number.");
    java8Reminder = prop.getLong(0);
    prop.setLanguageKey("forge.configgui.java8Reminder");
    propOrder.add(prop.getName());
    prop = config.get(Configuration.CATEGORY_CLIENT, "disableStairSlabCulling", false, "Disable culling of hidden faces next to stairs and slabs. Causes extra rendering, but may fix some resource packs that exploit this vanilla mechanic.");
    disableStairSlabCulling = prop.getBoolean(false);
    prop.setLanguageKey("forge.configgui.disableStairSlabCulling");
    propOrder.add(prop.getName());
    prop = config.get(Configuration.CATEGORY_CLIENT, "alwaysSetupTerrainOffThread", false, "Enable forge to queue all chunk updates to the Chunk Update thread. May increase FPS significantly, but may also cause weird rendering lag. Not recommended for computers " + "without a significant number of cores available.");
    alwaysSetupTerrainOffThread = prop.getBoolean(false);
    prop.setLanguageKey("forge.configgui.alwaysSetupTerrainOffThread");
    propOrder.add(prop.getName());
    config.setCategoryPropertyOrder(CATEGORY_CLIENT, propOrder);
    if (config.hasChanged()) {
        config.save();
    }
}
Also used : ArrayList(java.util.ArrayList) Property(net.minecraftforge.common.config.Property)

Example 2 with Property

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

the class ForgeChunkManager method syncConfigDefaults.

/**
     * Synchronizes the local fields with the values in the Configuration object.
     */
public static void syncConfigDefaults() {
    // By adding a property order list we are defining the order that the properties will appear both in the config file and on the GUIs.
    // Property order lists are defined per-ConfigCategory.
    List<String> propOrder = new ArrayList<String>();
    config.setCategoryComment("defaults", "Default configuration for forge chunk loading control").setCategoryRequiresWorldRestart("defaults", true);
    Property temp = config.get("defaults", "enabled", true);
    temp.setComment("Are mod overrides enabled?");
    temp.setLanguageKey("forge.configgui.enableModOverrides");
    overridesEnabled = temp.getBoolean(true);
    propOrder.add("enabled");
    temp = config.get("defaults", "maximumChunksPerTicket", 25);
    temp.setComment("The default maximum number of chunks a mod can force, per ticket, \n" + "for a mod without an override. This is the maximum number of chunks a single ticket can force.");
    temp.setLanguageKey("forge.configgui.maximumChunksPerTicket");
    temp.setMinValue(0);
    defaultMaxChunks = temp.getInt(25);
    propOrder.add("maximumChunksPerTicket");
    temp = config.get("defaults", "maximumTicketCount", 200);
    temp.setComment("The default maximum ticket count for a mod which does not have an override\n" + "in this file. This is the number of chunk loading requests a mod is allowed to make.");
    temp.setLanguageKey("forge.configgui.maximumTicketCount");
    temp.setMinValue(0);
    defaultMaxCount = temp.getInt(200);
    propOrder.add("maximumTicketCount");
    temp = config.get("defaults", "playerTicketCount", 500);
    temp.setComment("The number of tickets a player can be assigned instead of a mod. This is shared across all mods and it is up to the mods to use it.");
    temp.setLanguageKey("forge.configgui.playerTicketCount");
    temp.setMinValue(0);
    playerTicketLength = temp.getInt(500);
    propOrder.add("playerTicketCount");
    temp = config.get("defaults", "dormantChunkCacheSize", 0);
    temp.setComment("Unloaded chunks can first be kept in a dormant cache for quicker\n" + "loading times. Specify the size (in chunks) of that cache here");
    temp.setLanguageKey("forge.configgui.dormantChunkCacheSize");
    temp.setMinValue(0);
    dormantChunkCacheSize = temp.getInt(0);
    propOrder.add("dormantChunkCacheSize");
    FMLLog.info("Configured a dormant chunk cache size of %d", temp.getInt(0));
    config.setCategoryPropertyOrder("defaults", propOrder);
    config.addCustomCategoryComment(ForgeVersion.MOD_ID, "Sample mod specific control section.\n" + "Copy this section and rename the with the modid for the mod you wish to override.\n" + "A value of zero in either entry effectively disables any chunkloading capabilities\n" + "for that mod");
    temp = config.get(ForgeVersion.MOD_ID, "maximumTicketCount", 200);
    temp.setComment("Maximum ticket count for the mod. Zero disables chunkloading capabilities.");
    temp = config.get(ForgeVersion.MOD_ID, "maximumChunksPerTicket", 25);
    temp.setComment("Maximum chunks per ticket for the mod.");
    for (String mod : config.getCategoryNames()) {
        if (mod.equals(ForgeVersion.MOD_ID) || mod.equals("defaults")) {
            continue;
        }
        config.get(mod, "maximumTicketCount", 200).setLanguageKey("forge.configgui.maximumTicketCount").setMinValue(0);
        config.get(mod, "maximumChunksPerTicket", 25).setLanguageKey("forge.configgui.maximumChunksPerTicket").setMinValue(0);
    }
    if (config.hasChanged()) {
        config.save();
    }
}
Also used : ArrayList(java.util.ArrayList) Property(net.minecraftforge.common.config.Property)

Example 3 with Property

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

the class ForgeChunkManager method loadConfiguration.

static void loadConfiguration() {
    ticketConstraints.clear();
    chunkConstraints.clear();
    for (String mod : config.getCategoryNames()) {
        if (mod.equals(ForgeVersion.MOD_ID) || mod.equals("defaults")) {
            continue;
        }
        Property modTC = config.get(mod, "maximumTicketCount", 200);
        Property modCPT = config.get(mod, "maximumChunksPerTicket", 25);
        ticketConstraints.put(mod, modTC.getInt(200));
        chunkConstraints.put(mod, modCPT.getInt(25));
    }
    if (config.hasChanged()) {
        config.save();
    }
}
Also used : Property(net.minecraftforge.common.config.Property)

Example 4 with Property

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

the class ForgeChunkManager method addConfigProperty.

public static void addConfigProperty(Object mod, String propertyName, String value, Property.Type type) {
    ModContainer container = getContainer(mod);
    if (container != null) {
        ConfigCategory cat = config.getCategory(container.getModId());
        Property prop = new Property(propertyName, value, type).setLanguageKey("forge.configgui." + propertyName);
        if (type == Property.Type.INTEGER) {
            prop.setMinValue(0);
        }
        cat.put(propertyName, prop);
    }
}
Also used : ModContainer(net.minecraftforge.fml.common.ModContainer) ConfigCategory(net.minecraftforge.common.config.ConfigCategory) Property(net.minecraftforge.common.config.Property)

Example 5 with Property

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

the class ForgeModContainer method updateNag.

public static void updateNag() {
    Property prop = config.get(Configuration.CATEGORY_CLIENT, "java8Reminder", java8Reminder);
    prop.set((new Date()).getTime());
    config.save();
}
Also used : Property(net.minecraftforge.common.config.Property) Date(java.util.Date)

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