Skip to content

Commit

Permalink
Merge pull request #607 from ferriarnus/config-double
Browse files Browse the repository at this point in the history
Change configs to use Doubles
  • Loading branch information
Rover656 authored Feb 7, 2024
2 parents 767d349 + 8e9deb0 commit 9a74735
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ public class ArmoryCommonConfig {
public final ForgeConfigSpec.ConfigValue<Integer> EMPOWERED_EFFICIENCY_BOOST;
public final ForgeConfigSpec.ConfigValue<Integer> EMPOWERED_ENERGY_PER_DAMAGE;
public final ForgeConfigSpec.ConfigValue<Integer> EMPOWERED_ACTIVATION_COST_I;
public final ForgeConfigSpec.ConfigValue<Float> EMPOWERED_DAMAGE_ABSORPTION_CHANCE_I;
public final ForgeConfigSpec.ConfigValue<Double> EMPOWERED_DAMAGE_ABSORPTION_CHANCE_I;
public final ForgeConfigSpec.ConfigValue<Integer> EMPOWERED_MAX_ENERGY_I;
public final ForgeConfigSpec.ConfigValue<Integer> EMPOWERED_ACTIVATION_COST_II;
public final ForgeConfigSpec.ConfigValue<Float> EMPOWERED_DAMAGE_ABSORPTION_CHANCE_II;
public final ForgeConfigSpec.ConfigValue<Double> EMPOWERED_DAMAGE_ABSORPTION_CHANCE_II;
public final ForgeConfigSpec.ConfigValue<Integer> EMPOWERED_MAX_ENERGY_II;
public final ForgeConfigSpec.ConfigValue<Integer> EMPOWERED_ACTIVATION_COST_III;
public final ForgeConfigSpec.ConfigValue<Float> EMPOWERED_DAMAGE_ABSORPTION_CHANCE_III;
public final ForgeConfigSpec.ConfigValue<Double> EMPOWERED_DAMAGE_ABSORPTION_CHANCE_III;
public final ForgeConfigSpec.ConfigValue<Integer> EMPOWERED_MAX_ENERGY_III;
public final ForgeConfigSpec.ConfigValue<Integer> EMPOWERED_ACTIVATION_COST_IV;
public final ForgeConfigSpec.ConfigValue<Float> EMPOWERED_DAMAGE_ABSORPTION_CHANCE_IV;
public final ForgeConfigSpec.ConfigValue<Double> EMPOWERED_DAMAGE_ABSORPTION_CHANCE_IV;
public final ForgeConfigSpec.ConfigValue<Integer> EMPOWERED_MAX_ENERGY_IV;

public final ForgeConfigSpec.ConfigValue<Integer> EXPLOSIVE_RADIUS_ACTIVATION_COST_I;
Expand Down Expand Up @@ -56,16 +56,16 @@ public ArmoryCommonConfig(ForgeConfigSpec.Builder builder) {
EMPOWERED_EFFICIENCY_BOOST = builder.define("efficiencyBoost", 2);
EMPOWERED_ENERGY_PER_DAMAGE = builder.define("energyUsePerDamagePoint", 750);
EMPOWERED_ACTIVATION_COST_I = builder.define("activationCost_l1", 4);
EMPOWERED_DAMAGE_ABSORPTION_CHANCE_I = builder.define("damageAbsorptionChance_l1", 0.5f);
EMPOWERED_DAMAGE_ABSORPTION_CHANCE_I = builder.define("damageAbsorptionChance_l1", 0.5d);
EMPOWERED_MAX_ENERGY_I = builder.define("maxEnergy_l1", 100000);
EMPOWERED_ACTIVATION_COST_II = builder.define("activationCost_l2", 8);
EMPOWERED_DAMAGE_ABSORPTION_CHANCE_II = builder.define("damageAbsorptionChance_l2", 0.6f);
EMPOWERED_DAMAGE_ABSORPTION_CHANCE_II = builder.define("damageAbsorptionChance_l2", 0.6d);
EMPOWERED_MAX_ENERGY_II = builder.define("maxEnergy_l2", 150000);
EMPOWERED_ACTIVATION_COST_III = builder.define("activationCost_l3", 12);
EMPOWERED_DAMAGE_ABSORPTION_CHANCE_III = builder.define("damageAbsorptionChance_l3", 0.7f);
EMPOWERED_DAMAGE_ABSORPTION_CHANCE_III = builder.define("damageAbsorptionChance_l3", 0.7d);
EMPOWERED_MAX_ENERGY_III = builder.define("maxEnergy_l3", 250000);
EMPOWERED_ACTIVATION_COST_IV = builder.define("activationCost_l4", 16);
EMPOWERED_DAMAGE_ABSORPTION_CHANCE_IV = builder.define("damageAbsorptionChance_l4", 0.85f);
EMPOWERED_DAMAGE_ABSORPTION_CHANCE_IV = builder.define("damageAbsorptionChance_l4", 0.85d);
EMPOWERED_MAX_ENERGY_IV = builder.define("maxEnergy_l4", 1000000);
builder.pop();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ public enum EmpoweredUpgradeTier implements IUpgradeTier {

private final Supplier<IDarkSteelUpgrade> factory;
private final ForgeConfigSpec.ConfigValue<Integer> maxStorage;
private final ForgeConfigSpec.ConfigValue<Float> damageAbsorptionChance;
private final ForgeConfigSpec.ConfigValue<Double> damageAbsorptionChance;
private final ForgeConfigSpec.ConfigValue<Integer> activationCost;
private final Component displayName;

EmpoweredUpgradeTier(ForgeConfigSpec.ConfigValue<Integer> maxStorage, ForgeConfigSpec.ConfigValue<Float> damageAbsorptionChance,
EmpoweredUpgradeTier(ForgeConfigSpec.ConfigValue<Integer> maxStorage, ForgeConfigSpec.ConfigValue<Double> damageAbsorptionChance,
ForgeConfigSpec.ConfigValue<Integer> activationCost, Component displayName) {
this.maxStorage = maxStorage;
this.damageAbsorptionChance = damageAbsorptionChance;
Expand All @@ -47,7 +47,7 @@ public int getMaxStorage() {
}

public float getDamageAbsorptionChance() {
return damageAbsorptionChance.get();
return damageAbsorptionChance.get().floatValue();
}

public Supplier<IDarkSteelUpgrade> getFactory() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ private GhostRenderLayer(RenderType original) {

RenderSystem.disableDepthTest();
RenderSystem.enableBlend();
RenderSystem.setShaderColor(1, 1, 1, MachinesConfig.CLIENT.IO_CONFIG_NEIGHBOUR_TRANSPARENCY.get());
RenderSystem.setShaderColor(1, 1, 1, MachinesConfig.CLIENT.IO_CONFIG_NEIGHBOUR_TRANSPARENCY.get().floatValue());
},
() -> {
RenderSystem.setShaderColor(1, 1, 1, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ public class MachinesClientConfig {

public final MachinesClientBlocksConfig BLOCKS;

public final ForgeConfigSpec.ConfigValue<Float> IO_CONFIG_NEIGHBOUR_TRANSPARENCY;
public final ForgeConfigSpec.ConfigValue<Double> IO_CONFIG_NEIGHBOUR_TRANSPARENCY;

public MachinesClientConfig(ForgeConfigSpec.Builder builder) {
BLOCKS = new MachinesClientBlocksConfig(builder);

builder.push("ioconfig");
IO_CONFIG_NEIGHBOUR_TRANSPARENCY = builder.comment("Neighbour Transparency [0-1]").define("neighbourTransparency", 0.4F);
IO_CONFIG_NEIGHBOUR_TRANSPARENCY = builder.comment("Neighbour Transparency [0-1]").define("neighbourTransparency", 0.4d);
builder.pop();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public EnergyConfig(ForgeConfigSpec.Builder builder) {

builder.push("stirlingGenerator");
STIRLING_GENERATOR_CAPACITY = builder.comment("The base energy capacity in uI.").defineInRange("capacity", 64_000, 1, Integer.MAX_VALUE);
STIRLING_GENERATOR_BURN_SPEED = builder.comment("The base number of 'burn ticks' performed per machine tick.").defineInRange("burnSpeed", 0.375, 0.001, Double.MAX_VALUE);
STIRLING_GENERATOR_BURN_SPEED = builder.comment("The base number of 'burn ticks' performed per machine tick.").defineInRange("burnSpeed", 0.375d, 0.001d, Double.MAX_VALUE);
STIRLING_GENERATOR_PRODUCTION = builder.comment("The base amount of energy produced in uI/t.").defineInRange("generation", 40, 1, Integer.MAX_VALUE);
builder.pop();

Expand Down Expand Up @@ -120,7 +120,7 @@ public EnergyConfig(ForgeConfigSpec.Builder builder) {
builder.push("soul_engine");
SOUL_ENGINE_CAPACITY = builder.defineInRange("capacity",100000, 1, Integer.MAX_VALUE);
SOUL_ENGINE_BURN_SPEED = builder.comment("The base burn-rate the soul engine.").defineInRange("burnSpeed", 1, 1, Integer.MAX_VALUE);
SOUL_ENGINE_GENERATION = builder.comment("Percentage increase in uI produced.").defineInRange("generation", 1.0, 0.001, Double.MAX_VALUE);
SOUL_ENGINE_GENERATION = builder.comment("Percentage increase in uI produced.").defineInRange("generation", 1.0, 0.001d, Double.MAX_VALUE);

builder.pop();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

public class MachinesCommonConfig {
public final EnergyConfig ENERGY;
public final ForgeConfigSpec.ConfigValue<Float> ENCHANTER_LAPIS_COST_FACTOR;
public final ForgeConfigSpec.ConfigValue<Float> ENCHANTER_LEVEL_COST_FACTOR;
public final ForgeConfigSpec.ConfigValue<Double> ENCHANTER_LAPIS_COST_FACTOR;
public final ForgeConfigSpec.ConfigValue<Double> ENCHANTER_LEVEL_COST_FACTOR;
public final ForgeConfigSpec.ConfigValue<Integer> ENCHANTER_BASE_LEVEL_COST;
public final ForgeConfigSpec.ConfigValue<Integer> MAX_SPAWNER_ENTITIES;
public final ForgeConfigSpec.ConfigValue<Integer> MAX_SPAWNERS;
Expand All @@ -17,8 +17,8 @@ public MachinesCommonConfig(ForgeConfigSpec.Builder builder) {
ENERGY = new EnergyConfig(builder);

builder.push("enchanter");
ENCHANTER_LAPIS_COST_FACTOR = builder.comment("The lapis cost is enchant level multiplied by this value.").define("lapisCostFactor", 3.0f);
ENCHANTER_LEVEL_COST_FACTOR = builder.comment("The final XP cost for an enchantment is multiplied by this value. To halve costs set to 0.5, to double them set it to 2.").define("levelCostFactor", 0.75f);
ENCHANTER_LAPIS_COST_FACTOR = builder.comment("The lapis cost is enchant level multiplied by this value.").define("lapisCostFactor", 3.0d);
ENCHANTER_LEVEL_COST_FACTOR = builder.comment("The final XP cost for an enchantment is multiplied by this value. To halve costs set to 0.5, to double them set it to 2.").define("levelCostFactor", 0.75d);
ENCHANTER_BASE_LEVEL_COST = builder.comment("Base level cost added to all recipes in the enchanter.").define("baseLevelCost", 2);
builder.pop();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public int getEnchantmentLevel(int ingredientCount) {
*/
public int getLapisForLevel(int level) {
int res = getEnchantment().getMaxLevel() == 1 ? 5 : level;
return Math.max(1, Math.round(res * MachinesConfig.COMMON.ENCHANTER_LAPIS_COST_FACTOR.get()));
return Math.max(1, Math.round(res * MachinesConfig.COMMON.ENCHANTER_LAPIS_COST_FACTOR.get().floatValue()));
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package com.enderio.base.common.block.glass;

import com.enderio.EnderIO;
import com.enderio.base.common.config.BaseConfig;
import com.enderio.base.common.lang.EIOLang;
import net.minecraft.Util;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.DyeColor;
Expand Down Expand Up @@ -76,7 +74,7 @@ public int getLightBlock(BlockState pState, BlockGetter pLevel, BlockPos pPos) {

@Override
public float getExplosionResistance() {
return explosionResistant ? BaseConfig.COMMON.BLOCKS.EXPLOSION_RESISTANCE.get() : super.getExplosionResistance();
return explosionResistant ? BaseConfig.COMMON.BLOCKS.EXPLOSION_RESISTANCE.get().floatValue() : super.getExplosionResistance();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
import net.minecraftforge.common.ForgeConfigSpec;

public class BlocksConfig {
public final ForgeConfigSpec.ConfigValue<Float> BROKEN_SPAWNER_DROP_CHANCE;
public final ForgeConfigSpec.ConfigValue<Float> EXPLOSION_RESISTANCE;
public final ForgeConfigSpec.ConfigValue<Float> DARK_STEEL_LADDER_BOOST;
public final ForgeConfigSpec.ConfigValue<Double> BROKEN_SPAWNER_DROP_CHANCE;
public final ForgeConfigSpec.ConfigValue<Double> EXPLOSION_RESISTANCE;
public final ForgeConfigSpec.ConfigValue<Double> DARK_STEEL_LADDER_BOOST;

public BlocksConfig(ForgeConfigSpec.Builder builder) {
builder.push("blocks");

builder.push("brokenSpawner");
BROKEN_SPAWNER_DROP_CHANCE = builder.comment("The chance of a spawner dropping a broken spawner.").define("dropChance", 1.0f);
BROKEN_SPAWNER_DROP_CHANCE = builder.comment("The chance of a spawner dropping a broken spawner.").define("dropChance", 1.0d);
builder.pop();

EXPLOSION_RESISTANCE = builder.comment("The explosion resistance of explosion resistant blocks.").define("explosionResistance", 1200.0f);
EXPLOSION_RESISTANCE = builder.comment("The explosion resistance of explosion resistant blocks.").define("explosionResistance", 1200.0d);

DARK_STEEL_LADDER_BOOST = builder.comment("The speed boost granted by the Dark Steel ladder.").define("darkSteelLadderBoost", 0.15f);
DARK_STEEL_LADDER_BOOST = builder.comment("The speed boost granted by the Dark Steel ladder.").define("darkSteelLadderBoost", 0.15d);
builder.pop();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ public class EnchantmentsConfig {
public final ForgeConfigSpec.ConfigValue<Integer> REPELLENT_MAX_COST_MULT;
public final ForgeConfigSpec.ConfigValue<Integer> REPELLENT_MIN_COST_BASE;
public final ForgeConfigSpec.ConfigValue<Integer> REPELLENT_MIN_COST_MULT;
public final ForgeConfigSpec.ConfigValue<Float> REPELLENT_CHANCE_BASE;
public final ForgeConfigSpec.ConfigValue<Float> REPELLENT_CHANCE_MULT;
public final ForgeConfigSpec.ConfigValue<Double> REPELLENT_CHANCE_BASE;
public final ForgeConfigSpec.ConfigValue<Double> REPELLENT_CHANCE_MULT;
public final ForgeConfigSpec.ConfigValue<Double> REPELLENT_RANGE_BASE;
public final ForgeConfigSpec.ConfigValue<Double> REPELLENT_RANGE_MULT;
public final ForgeConfigSpec.ConfigValue<Float> REPELLENT_NON_PLAYER_CHANCE;
public final ForgeConfigSpec.ConfigValue<Double> REPELLENT_NON_PLAYER_CHANCE;

public final ForgeConfigSpec.ConfigValue<Integer> SHIMMER_MAX_COST;
public final ForgeConfigSpec.ConfigValue<Integer> SHIMMER_MIN_COST;
Expand Down Expand Up @@ -51,11 +51,11 @@ public EnchantmentsConfig(ForgeConfigSpec.Builder builder) {
REPELLENT_MAX_COST_MULT = builder.define("maxCostPerLevel", 10);
REPELLENT_MIN_COST_BASE = builder.define("minCostBase", 10);
REPELLENT_MIN_COST_MULT = builder.define("minCostPerLevel", 5);
REPELLENT_CHANCE_BASE = builder.define("chanceBase", 0.35f);
REPELLENT_CHANCE_MULT = builder.define("chancePerLevel", 0.1f);
REPELLENT_CHANCE_BASE = builder.define("chanceBase", 0.35d);
REPELLENT_CHANCE_MULT = builder.define("chancePerLevel", 0.1d);
REPELLENT_RANGE_BASE = builder.define("rangeBase", 8d);
REPELLENT_RANGE_MULT = builder.define("rangePerLevel", 8d);
REPELLENT_NON_PLAYER_CHANCE = builder.define("nonPlayerChance", 0.75f);
REPELLENT_NON_PLAYER_CHANCE = builder.define("nonPlayerChance", 0.75d);
builder.pop();

builder.push("shimmer");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import net.minecraftforge.common.ForgeConfigSpec;

public class ItemsConfig {
public final ForgeConfigSpec.ConfigValue<Float> ENDERIOS_CHANCE;
public final ForgeConfigSpec.ConfigValue<Float> ENDERIOS_RANGE;
public final ForgeConfigSpec.ConfigValue<Double> ENDERIOS_CHANCE;
public final ForgeConfigSpec.ConfigValue<Double> ENDERIOS_RANGE;

public final ForgeConfigSpec.ConfigValue<Integer> ELECTROMAGNET_ENERGY_USE;
public final ForgeConfigSpec.ConfigValue<Integer> ELECTROMAGNET_MAX_ENERGY;
Expand All @@ -26,8 +26,8 @@ public ItemsConfig(ForgeConfigSpec.Builder builder) {
builder.push("items");

builder.push("food");
ENDERIOS_CHANCE = builder.comment("The chance of enderios teleporting the player").define("enderioChance", 0.3f);
ENDERIOS_RANGE = builder.comment("The range of an enderio teleport").define("enderioRange", 16.0f);
ENDERIOS_CHANCE = builder.comment("The chance of enderios teleporting the player").define("enderioChance", 0.3d);
ENDERIOS_RANGE = builder.comment("The range of an enderio teleport").define("enderioRange", 16.0d);
builder.pop();

builder.push("electromagnet");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public int getMinCost(int pLevel) {
}

private float getChance(int level) {
return BaseConfig.COMMON.ENCHANTMENTS.REPELLENT_CHANCE_BASE.get() + BaseConfig.COMMON.ENCHANTMENTS.REPELLENT_CHANCE_MULT.get() * level;
return BaseConfig.COMMON.ENCHANTMENTS.REPELLENT_CHANCE_BASE.get().floatValue() + BaseConfig.COMMON.ENCHANTMENTS.REPELLENT_CHANCE_MULT.get().floatValue() * level;
}

private double getRange(int level) {
Expand Down

0 comments on commit 9a74735

Please sign in to comment.