net.minecraftforge.common.ForgeConfigSpec Java Examples

The following examples show how to use net.minecraftforge.common.ForgeConfigSpec. 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: ModConfig.java    From patchwork-api with GNU Lesser General Public License v2.1 5 votes vote down vote up
public ModConfig(final Type type, final ForgeConfigSpec spec, final ModContainer container, final String fileName) {
	this.type = type;
	this.spec = spec;
	this.fileName = fileName;
	this.container = container;
	this.configHandler = ConfigFileTypeHandler.TOML;
	ConfigTracker.INSTANCE.trackConfig(this);
}
 
Example #2
Source File: Config.java    From MiningGadgets with MIT License 5 votes vote down vote up
public static void loadConfig(ForgeConfigSpec spec, Path path) {

        final CommentedFileConfig configData = CommentedFileConfig.builder(path)
                .sync()
                .autosave()
                .writingMode(WritingMode.REPLACE)
                .build();

        configData.load();
        spec.setConfig(configData);
    }
 
Example #3
Source File: BetterSprintingConfig.java    From Better-Sprinting with Mozilla Public License 2.0 5 votes vote down vote up
public static void register(ModLoadingContext context, ModConfig.Type type, ForgeConfigSpec spec, String suffix){
	String fileName = BetterSprintingMod.id + "-" + suffix + ".toml";
	context.registerConfig(type, spec, fileName);
	
	if (Files.notExists(Paths.get("config", fileName))){
		migrationFile = Paths.get("config", "bettersprinting.cfg").toAbsolutePath();
		isNew = true; // since keybinds are not migrated and first time setup only modifies keybinds, this is fine
	}
}
 
Example #4
Source File: ModLoadingContext.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void registerConfig(ModConfig.Type type, ForgeConfigSpec spec) {
	getActiveContainer().addConfig(new ModConfig(type, spec, getActiveContainer()));
}
 
Example #5
Source File: ModLoadingContext.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void registerConfig(ModConfig.Type type, ForgeConfigSpec spec, String fileName) {
	getActiveContainer().addConfig(new ModConfig(type, spec, getActiveContainer(), fileName));
}
 
Example #6
Source File: ModConfig.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
public ModConfig(final Type type, final ForgeConfigSpec spec, final ModContainer activeContainer) {
	this(type, spec, activeContainer, defaultConfigName(type, activeContainer.getModId()));
}
 
Example #7
Source File: ModConfig.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
public ForgeConfigSpec getSpec() {
	return spec;
}
 
Example #8
Source File: ConfigManager.java    From Survivalist with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
ServerConfig(ForgeConfigSpec.Builder builder)
{
    builder.comment("Settings for stick crafting").push("sticks");
    removeSticksFromPlanks = builder.define("RemoveSticksFromPlanksRecipes", true);
    builder.pop();
    builder.comment("Settings for rock and ore rock drops").push("rocks");
    enableRocks = builder.define("Enable", true);
    replaceStoneDrops = builder.define("ReplaceStoneDrops", true);
    replaceIronOreDrops = builder.define("ReplaceIronOreDrops", true);
    replaceGoldOreDrops = builder.define("ReplaceGoldOreDrops", true);
    replaceModOreDrops = builder.define("ReplaceModOreDrops", true);
    replacePoorOreDrops = builder.define("ReplacePoorOreDrops", true);
    cobbleRequiresClay = builder.define("CobbleRequiresClay", true);
    builder.pop();
    builder.comment("Settings for the Scraping feature and enchant").push("scraping");
    enableScraping = builder.define("Enable", false);
    scrapingIsTreasure = builder.define("IsTreasureEnchantment", false);
    enableToolScraping = builder.define("EnableToolScraping", true);
    enableArmorScraping = builder.define("EnableArmorScraping", true);
    builder.pop();
    builder.comment("Settings for the drying rack block").push("drying_rack");
    enableMeatRotting = builder.define("EnableMeatRotting", true);
    enableRottenDrying = builder.define("EnableRottenDrying", true);
    enableJerky = builder.define("EnableJerky", true);
    enableMeatDrying = builder.define("EnableMeatDrying", true);
    enableLeatherTanning = builder.define("EnableLeatherTanning", true);
    enableSaddleCrafting = builder.define("EnableSaddleCrafting", true);
    builder.pop();
    builder.comment("Settings for the torch setting fire to entities").push("torch_fire");
    enableTorchFire = builder.define("Enable", true);
    builder.pop();

    builder.comment("Settings for the dough/bread replacements").push("bread");
    enableBread = builder.define("Enable", true);
    removeVanillaBread = builder.define("RemoveVanillaBread", true);
    builder.pop();

    builder.comment("Settings for the chopping block").push("chopping");
    disablePlanksRecipes = builder.define("DisablePlanksRecipes", true);
    choppingDegradeChance = builder
            .comment("The average number of uses before degrading to the next phase will be 1/DegradeChance. Default is 16.67 average uses.")
            .defineInRange("DegradeChance", 0.06, 0, Double.MAX_VALUE);
    choppingExhaustion = builder.defineInRange("Exhaustion", 0.0025, 0, Double.MAX_VALUE);
    choppingWithEmptyHand = builder.defineInRange("EmptyHandFactor", 0.4, 0, Double.MAX_VALUE);
    builder.pop();

    builder.comment("Settings for the fibre collection").push("fibres");
    dropStringFromSheep = builder.define("DropStringFromSheep", true);
    enableStringCrafting = builder.define("EnableStringCrafting", true);
    builder.pop();

    builder.comment("Settings for slime merging").push("slimes");
    mergeSlimes = builder
            .comment("If enabled, slimes will have new AI rules to feel attracted to other slimes, and if 4 slimes of the same size are nearby they will merge into a slime of higher size.")
            .define("Merge", true);
    builder.pop();


    axeLevels = builder
            .comment("If enabled, slimes will have new AI rules to feel attracted to other slimes, and if 4 slimes of the same size are nearby they will merge into a slime of higher size.")
            .define(Arrays.asList("axe_levels"), () -> Config.of(InMemoryFormat.defaultInstance()), x -> true, Config.class);

/*
configuration.addCustomCategoryComment("AxeMultipliers",
        "Allows customizing the multiplier for each axe level. By default this is 'baseOutput * (1+axeLevel)'.\n" +
                "To customize an axeLevel, add a line like 'D:AxeLevel1=2.0' or 'D:AxeLevel5=3.0' without the quotes.\n" +
                "Levels that are not defined will continue using their default value."
);
axeMultipliers = configuration.getCategory("AxeMultipliers");

 */
}
 
Example #9
Source File: ConfigManager.java    From Survivalist with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public static boolean getConfigBoolean(String categoryName, String keyName)
{
    ForgeConfigSpec.BooleanValue value = SERVER_SPEC.getValues().get(Arrays.asList(categoryName, keyName));
    return value.get();
}