Started implementing config files for totems.

This commit is contained in:
2022-01-09 19:25:43 +00:00
parent eb9e7d5e5c
commit 50474bf894

View File

@ -4,6 +4,8 @@ import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.config.ModConfig;
import java.util.HashMap;
public final class Config {
public static void init() {
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, Common.spec);
@ -29,12 +31,75 @@ public final class Config {
}
}
public static final class Server {
static ForgeConfigSpec spec = null;
public final class Server {
static ForgeConfigSpec spec;
public static final HashMap<String, TotemConfig> TOTEM_CONFIGS = new HashMap<>();
Server() {
ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder();
/*
Straw Totem
Iron Totem
Diamond Totem
Coal Totem
Lapis Totem
Gold Totem
Redstone Totem
Emerald Totem
Quartz Totem
Prismarine Totem
Glowstone Totem
Netherite Totem
*/
TOTEM_CONFIGS.put("Straw Totem", new TotemConfig("Straw Totem", builder,
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();
}
public class TotemConfig {
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,
double chargeCostMultiplier, boolean canReviveMoreExpensiveTargets, int durability) {
NAME = totemName;
builder.push(NAME);
IS_ENABLED = builder
.comment("Is the " + NAME + " enabled?")
.define("isEnabled", isEnabled);
CHARGE_COST = builder
.comment("The charge cost to revive a player.\n" +
"-1 means the cost is dynamic (follows the amount of deaths the target has)\n" +
"Higher values set the charge cost to static, meaning that this will be the amount of charges needed to revive someone.")
.defineInRange("chargeCost", chargeCost, -1, Integer.MAX_VALUE);
CHARGE_COST_LIMIT = builder
.comment("The max amount of charge this totem can hold at once.\n" +
"0 means unlimited. Only works with dynamic cost.")
.defineInRange("chargeCostLimit", chargeCostLimit, 0, Integer.MAX_VALUE);
CHARGE_COST_MULTIPLIER = builder
.comment("Charge cost multiplier. 0.5 means the charge cost will be 50% of the original cost. Only works with dynamic cost.")
.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();
}
}
}
}