Posted March 22, 20232 yr 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; }; } }
March 23, 20232 yr 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.