Removed unused Client and Common configs. Removed future totems for now. Updated TotemConfig class.

This commit is contained in:
2022-01-12 17:20:06 +00:00
parent 3097334020
commit caf5d4037f

View File

@ -1,42 +1,21 @@
package dev.micle.totemofreviving.config; package dev.micle.totemofreviving.config;
import dev.micle.totemofreviving.item.StrawTotemItem;
import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.config.ModConfig; import net.minecraftforge.fml.config.ModConfig;
import java.util.HashMap;
public final class Config { public final class Config {
public static void init() { public static void init() {
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, Common.spec); ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, Server.SPEC);
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, Client.spec);
ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, Server.spec);
} }
public static final class Common { public static final class Server {
static ForgeConfigSpec spec = null; private static final ForgeConfigSpec SPEC;
Common() { private static final TotemConfig STRAW_TOTEM_CONFIG;
ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder();
spec = builder.build();
}
}
public static final class Client {
static ForgeConfigSpec spec = null;
Client() { static {
ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder();
spec = builder.build();
}
}
public final class Server {
static ForgeConfigSpec spec;
public static final HashMap<String, TotemConfig> TOTEM_CONFIGS = new HashMap<>();
Server() {
ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder(); ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder();
/* /*
Straw Totem Straw Totem
@ -53,53 +32,57 @@ public final class Config {
Glowstone Totem Glowstone Totem
Netherite Totem Netherite Totem
*/ */
TOTEM_CONFIGS.put("Straw Totem", new TotemConfig("Straw Totem", builder, STRAW_TOTEM_CONFIG = new TotemConfig(builder, StrawTotemItem.getName(),
true, -1, 3, 1, false, 3)); true, -1, 3, 1, false, 3);
TOTEM_CONFIGS.put("Iron Totem", new TotemConfig("Iron Totem", builder,
true, -1, 6, 0.75, false, 10)); SPEC = builder.build();
TOTEM_CONFIGS.put("Diamond Totem", new TotemConfig("Diamond Totem", builder,
true, -1, 0, 0.5, false, 50));
spec = builder.build();
} }
public class TotemConfig { public static TotemConfig getStrawTotemConfig() { return STRAW_TOTEM_CONFIG; }
public final String NAME; }
public final ForgeConfigSpec.BooleanValue IS_ENABLED;
public final ForgeConfigSpec.IntValue CHARGE_COST; public static class TotemConfig {
public final ForgeConfigSpec.IntValue CHARGE_COST_LIMIT; private final ForgeConfigSpec.BooleanValue IS_ENABLED;
public final ForgeConfigSpec.DoubleValue CHARGE_COST_MULTIPLIER; private final ForgeConfigSpec.IntValue CHARGE_COST;
public final ForgeConfigSpec.BooleanValue CAN_REVIVE_MORE_EXPENSIVE_TARGETS; private final ForgeConfigSpec.IntValue CHARGE_COST_LIMIT;
public final ForgeConfigSpec.IntValue DURABILITY; private final ForgeConfigSpec.DoubleValue CHARGE_COST_MULTIPLIER;
private final ForgeConfigSpec.BooleanValue CAN_REVIVE_MORE_EXPENSIVE_TARGETS;
TotemConfig(String totemName, ForgeConfigSpec.Builder builder, boolean isEnabled, int chargeCost, int chargeCostLimit, private final ForgeConfigSpec.IntValue DURABILITY;
double chargeCostMultiplier, boolean canReviveMoreExpensiveTargets, int durability) {
NAME = totemName; TotemConfig(ForgeConfigSpec.Builder builder, String name, boolean isEnabled, int chargeCost,
builder.push(NAME); int chargeCostLimit, double chargeCostMultiplier, boolean canReviveMoreExpensiveTargets,
IS_ENABLED = builder int durability) {
.comment("Is the " + NAME + " enabled?") builder.push(name);
.define("isEnabled", isEnabled); IS_ENABLED = builder
CHARGE_COST = builder .comment("Is the " + name + " enabled?")
.comment("The charge cost to revive a player.\n" + .define("isEnabled", isEnabled);
"-1 means the cost is dynamic (follows the amount of deaths the target has)\n" + CHARGE_COST = builder
"Higher values set the charge cost to static, meaning that this will be the amount of charges needed to revive someone.") .comment("The charge cost to revive a player.\n" +
.defineInRange("chargeCost", chargeCost, -1, Integer.MAX_VALUE); "-1 means the cost is dynamic (follows the amount of deaths the target has)\n" +
CHARGE_COST_LIMIT = builder "Higher values set the charge cost to static, meaning that this will be the amount of charges needed to revive someone.")
.comment("The max amount of charge this totem can hold at once.\n" + .defineInRange("chargeCost", chargeCost, -1, Integer.MAX_VALUE);
"0 means unlimited. Only works with dynamic cost.") CHARGE_COST_LIMIT = builder
.defineInRange("chargeCostLimit", chargeCostLimit, 0, Integer.MAX_VALUE); .comment("The max amount of charge this totem can hold at once.\n" +
CHARGE_COST_MULTIPLIER = builder "0 means unlimited. Only works with dynamic cost.")
.comment("Charge cost multiplier. 0.5 means the charge cost will be 50% of the original cost. Only works with dynamic cost.") .defineInRange("chargeCostLimit", chargeCostLimit, 0, Integer.MAX_VALUE);
.defineInRange("chargeCostMultiplier", chargeCostMultiplier, 0.01, Integer.MAX_VALUE); CHARGE_COST_MULTIPLIER = builder
CAN_REVIVE_MORE_EXPENSIVE_TARGETS = builder .comment("Charge cost multiplier. 0.5 means the charge cost will be 50% of the original cost. Only works with dynamic cost.")
.comment("Is the totem able to revive targets that cost more than the totems max charge?\n" + .defineInRange("chargeCostMultiplier", chargeCostMultiplier, 0.01, Integer.MAX_VALUE);
"This only applies if the totem is fully charged. (dynamic wont work if limit is 0)") CAN_REVIVE_MORE_EXPENSIVE_TARGETS = builder
.define("canReviveMoreExpensiveTargets", canReviveMoreExpensiveTargets); .comment("Is the totem able to revive targets that cost more than the totems max charge?\n" +
DURABILITY = builder "This only applies if the totem is fully charged. (dynamic wont work if limit is 0)")
.comment("The durability of the totem. 0 means unbreakable.") .define("canReviveMoreExpensiveTargets", canReviveMoreExpensiveTargets);
.defineInRange("durability", durability, 0, Integer.MAX_VALUE); DURABILITY = builder
builder.pop(); .comment("The durability of the totem. 0 means unbreakable.")
} .defineInRange("durability", durability, 0, Integer.MAX_VALUE);
builder.pop();
} }
public boolean getIsEnabled() { return IS_ENABLED.get(); }
public int getChargeCost() { return CHARGE_COST.get(); }
public int getChargeCostLimit() { return CHARGE_COST_LIMIT.get(); }
public double getChargeCostMultiplier() { return CHARGE_COST_MULTIPLIER.get(); }
public boolean getCanReviveMoreExpensiveTargets() { return CAN_REVIVE_MORE_EXPENSIVE_TARGETS.get(); }
public int getDurability() { return DURABILITY.get(); }
} }
} }