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 {
static ForgeConfigSpec spec = null;
Client() {
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));
TOTEM_CONFIGS.put("Diamond Totem", new TotemConfig("Diamond Totem", builder,
true, -1, 0, 0.5, false, 50));
spec = builder.build(); 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 final ForgeConfigSpec.IntValue CHARGE_COST_LIMIT;
public final ForgeConfigSpec.DoubleValue CHARGE_COST_MULTIPLIER;
public final ForgeConfigSpec.BooleanValue CAN_REVIVE_MORE_EXPENSIVE_TARGETS;
public final ForgeConfigSpec.IntValue DURABILITY;
TotemConfig(String totemName, ForgeConfigSpec.Builder builder, boolean isEnabled, int chargeCost, int chargeCostLimit, public static class TotemConfig {
double chargeCostMultiplier, boolean canReviveMoreExpensiveTargets, int durability) { private final ForgeConfigSpec.BooleanValue IS_ENABLED;
NAME = totemName; private final ForgeConfigSpec.IntValue CHARGE_COST;
builder.push(NAME); private final ForgeConfigSpec.IntValue CHARGE_COST_LIMIT;
IS_ENABLED = builder private final ForgeConfigSpec.DoubleValue CHARGE_COST_MULTIPLIER;
.comment("Is the " + NAME + " enabled?") private final ForgeConfigSpec.BooleanValue CAN_REVIVE_MORE_EXPENSIVE_TARGETS;
.define("isEnabled", isEnabled); private final ForgeConfigSpec.IntValue DURABILITY;
CHARGE_COST = builder
.comment("The charge cost to revive a player.\n" + TotemConfig(ForgeConfigSpec.Builder builder, String name, boolean isEnabled, int chargeCost,
"-1 means the cost is dynamic (follows the amount of deaths the target has)\n" + int chargeCostLimit, double chargeCostMultiplier, boolean canReviveMoreExpensiveTargets,
"Higher values set the charge cost to static, meaning that this will be the amount of charges needed to revive someone.") int durability) {
.defineInRange("chargeCost", chargeCost, -1, Integer.MAX_VALUE); builder.push(name);
CHARGE_COST_LIMIT = builder IS_ENABLED = builder
.comment("The max amount of charge this totem can hold at once.\n" + .comment("Is the " + name + " enabled?")
"0 means unlimited. Only works with dynamic cost.") .define("isEnabled", isEnabled);
.defineInRange("chargeCostLimit", chargeCostLimit, 0, Integer.MAX_VALUE); CHARGE_COST = builder
CHARGE_COST_MULTIPLIER = builder .comment("The charge cost to revive a player.\n" +
.comment("Charge cost multiplier. 0.5 means the charge cost will be 50% of the original cost. Only works with dynamic cost.") "-1 means the cost is dynamic (follows the amount of deaths the target has)\n" +
.defineInRange("chargeCostMultiplier", chargeCostMultiplier, 0.01, Integer.MAX_VALUE); "Higher values set the charge cost to static, meaning that this will be the amount of charges needed to revive someone.")
CAN_REVIVE_MORE_EXPENSIVE_TARGETS = builder .defineInRange("chargeCost", chargeCost, -1, Integer.MAX_VALUE);
.comment("Is the totem able to revive targets that cost more than the totems max charge?\n" + CHARGE_COST_LIMIT = builder
"This only applies if the totem is fully charged. (dynamic wont work if limit is 0)") .comment("The max amount of charge this totem can hold at once.\n" +
.define("canReviveMoreExpensiveTargets", canReviveMoreExpensiveTargets); "0 means unlimited. Only works with dynamic cost.")
DURABILITY = builder .defineInRange("chargeCostLimit", chargeCostLimit, 0, Integer.MAX_VALUE);
.comment("The durability of the totem. 0 means unbreakable.") CHARGE_COST_MULTIPLIER = builder
.defineInRange("durability", durability, 0, Integer.MAX_VALUE); .comment("Charge cost multiplier. 0.5 means the charge cost will be 50% of the original cost. Only works with dynamic cost.")
builder.pop(); .defineInRange("chargeCostMultiplier", chargeCostMultiplier, 0.01, Integer.MAX_VALUE);
} CAN_REVIVE_MORE_EXPENSIVE_TARGETS = builder
.comment("Is the totem able to revive targets that cost more than the totems max charge?\n" +
"This only applies if the totem is fully charged. (dynamic wont work if limit is 0)")
.define("canReviveMoreExpensiveTargets", canReviveMoreExpensiveTargets);
DURABILITY = builder
.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(); }
} }
} }