Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[1.19.2] Configurations with floating point numbers always beeing corrected

Featured Replies

Posted

Hi
In my mod these three configurations get corrected on each client launch. event if they are on default...

What am i doing wrong?

[09:03:33] [modloading-worker-0/WARN] [ne.mi.co.ForgeConfigSpec/CORE]: Incorrect key Configs for Futuristic Factories.ENERGY_UPGRADE_STORAGE_EFFECTIVITY was corrected from 1.0 to its default, 1.0. 
[09:03:33] [modloading-worker-0/WARN] [ne.mi.co.ForgeConfigSpec/CORE]: Incorrect key Configs for Futuristic Factories.ENERGY_UPGRADE_CONSUMPTION_EFFECTIVITY was corrected from 0.125 to its default, 0.125. 
[09:03:33] [modloading-worker-0/WARN] [ne.mi.co.ForgeConfigSpec/CORE]: Incorrect key Configs for Futuristic Factories.SPEED_UPGRADE_ENERGY_CONSUMPTION_MULTIPLIER was corrected from 1 to its default, 1. This seems to be an error.
 

package net.internalerror.futuristicfactories.fml.config;

import lombok.experimental.UtilityClass;
import net.minecraftforge.common.ForgeConfigSpec;

import java.util.function.Predicate;

/**
 * FuturisticFactories
 *
 * @author InternalErrorGit
 * @version 1.0 Snapshot
 */
@UtilityClass
public final class Configuration {

    public static final ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder();
    public static final ForgeConfigSpec SPEC;
    public static final ForgeConfigSpec.ConfigValue<Integer> CRUSHING_MACHINE_BASE_ENERGY_STORAGE;
    public static final ForgeConfigSpec.ConfigValue<Float> ENERGY_UPGRADE_STORAGE_EFFECTIVITY;
    public static final ForgeConfigSpec.ConfigValue<Integer> CRUSHING_MACHINE_BASE_ENERGY_CONSUMPTION;
    public static final ForgeConfigSpec.ConfigValue<Float> ENERGY_UPGRADE_CONSUMPTION_EFFECTIVITY;
    public static final ForgeConfigSpec.ConfigValue<Integer> SPEED_UPGRADE_ENERGY_CONSUMPTION_MULTIPLIER;

    static {
        BUILDER.push("Configs for Futuristic Factories");

        CRUSHING_MACHINE_BASE_ENERGY_STORAGE = BUILDER
                .comment("Base energy storage of the crushing machine")
                .define("CRUSHING_MACHINE_BASE_ENERGY_STORAGE", 16000);
        ENERGY_UPGRADE_STORAGE_EFFECTIVITY = BUILDER
                .comment("Energy storage upgrade effectivity (storage = baseStorage + (upgradeCount * (baseStorage*effectivity))")
                .define("ENERGY_UPGRADE_STORAGE_EFFECTIVITY", 1.0f);
        CRUSHING_MACHINE_BASE_ENERGY_CONSUMPTION = BUILDER
                .comment("Base energy consumption of the crushing machine in FE/tick")
                .define("CRUSHING_MACHINE_BASE_ENERGY_CONSUMPTION", 1024);
        ENERGY_UPGRADE_CONSUMPTION_EFFECTIVITY = BUILDER
                .comment("Energy consumption effectivity (consumption = baseConsumption -) (min: 0.01, max: 0.99)")
                .define("ENERGY_UPGRADE_CONSUMPTION_EFFECTIVITY", 0.125f, floatMinMaxValidator(0.01f, 0.99f));
        SPEED_UPGRADE_ENERGY_CONSUMPTION_MULTIPLIER = BUILDER
                .comment("Energy consumption multiplier by speed upgrade (min: 1, max: 5)")
                .define("SPEED_UPGRADE_ENERGY_CONSUMPTION_MULTIPLIER", 1, integerMinMaxValidator(1, 5));

        BUILDER.pop();
        SPEC = BUILDER.build();
    }

    public static Predicate<Object> integerMinMaxValidator(int pMin, int pMax) {
        return object -> {
            if (object instanceof Integer number)
                return number > pMin && number < pMax;
            return false;
        };
    }

    public static Predicate<Object> floatMinMaxValidator(float pMin, float pMax) {
        return object -> {
            if (object instanceof Float number)
                return number > pMin && number < pMax;
            return false;
        };
    }


}

 

First, I would use `#defineInRange` instead of making your own validator. Second, I would use the associated config value types like IntValue or DoubleValue (floats don't exist in toml).

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.