Ported config.
This commit is contained in:
@ -18,10 +18,10 @@ public final class TotemOfReviving {
|
|||||||
|
|
||||||
private static IProxy proxy;
|
private static IProxy proxy;
|
||||||
|
|
||||||
public TotemOfReviving(IEventBus modEventBus) {
|
public TotemOfReviving(IEventBus modEventBus, ModContainer modContainer) {
|
||||||
proxy = FMLEnvironment.dist == Dist.CLIENT
|
proxy = FMLEnvironment.dist == Dist.CLIENT
|
||||||
? new Proxy.Client(modEventBus)
|
? new Proxy.Client(modEventBus, modContainer)
|
||||||
: new Proxy.Server(modEventBus);
|
: new Proxy.Server(modEventBus, modContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ResourceLocation createResourceLocation(String name) {
|
public static ResourceLocation createResourceLocation(String name) {
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import net.minecraft.world.level.Level;
|
|||||||
import net.neoforged.api.distmarker.Dist;
|
import net.neoforged.api.distmarker.Dist;
|
||||||
import net.neoforged.api.distmarker.OnlyIn;
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
import net.neoforged.bus.api.IEventBus;
|
import net.neoforged.bus.api.IEventBus;
|
||||||
|
import net.neoforged.fml.ModContainer;
|
||||||
import net.neoforged.fml.event.lifecycle.*;
|
import net.neoforged.fml.event.lifecycle.*;
|
||||||
import net.neoforged.neoforge.common.NeoForge;
|
import net.neoforged.neoforge.common.NeoForge;
|
||||||
import net.neoforged.neoforge.event.AddReloadListenerEvent;
|
import net.neoforged.neoforge.event.AddReloadListenerEvent;
|
||||||
@ -21,10 +22,10 @@ public class Proxy implements IProxy {
|
|||||||
private static MinecraftServer server = null;
|
private static MinecraftServer server = null;
|
||||||
|
|
||||||
// Common setup
|
// Common setup
|
||||||
public Proxy(IEventBus modEventBus) {
|
public Proxy(IEventBus modEventBus, ModContainer modContainer) {
|
||||||
// Initialize setup
|
// Initialize setup
|
||||||
Registration.register();
|
Registration.register();
|
||||||
Config.init();
|
Config.init(modContainer);
|
||||||
NetworkManager.init();
|
NetworkManager.init();
|
||||||
|
|
||||||
// Register mod event bus listeners
|
// Register mod event bus listeners
|
||||||
@ -71,8 +72,8 @@ public class Proxy implements IProxy {
|
|||||||
|
|
||||||
// Client setup
|
// Client setup
|
||||||
public static class Client extends Proxy {
|
public static class Client extends Proxy {
|
||||||
public Client(IEventBus modEventBus) {
|
public Client(IEventBus modEventBus, ModContainer modContainer) {
|
||||||
super(modEventBus);
|
super(modEventBus, modContainer);
|
||||||
// Register mod event bus listeners
|
// Register mod event bus listeners
|
||||||
modEventBus.addListener(Client::setup);
|
modEventBus.addListener(Client::setup);
|
||||||
modEventBus.addListener(Client::postSetup);
|
modEventBus.addListener(Client::postSetup);
|
||||||
@ -97,8 +98,8 @@ public class Proxy implements IProxy {
|
|||||||
|
|
||||||
// Server setup
|
// Server setup
|
||||||
public static class Server extends Proxy {
|
public static class Server extends Proxy {
|
||||||
public Server(IEventBus modEventBus) {
|
public Server(IEventBus modEventBus, ModContainer modContainer) {
|
||||||
super(modEventBus);
|
super(modEventBus, modContainer);
|
||||||
// Register mod event bus listeners
|
// Register mod event bus listeners
|
||||||
modEventBus.addListener(Server::setup);
|
modEventBus.addListener(Server::setup);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,17 +4,17 @@ import dev.micle.totemofreviving.item.totem.DiamondTotemItem;
|
|||||||
import dev.micle.totemofreviving.item.totem.IronTotemItem;
|
import dev.micle.totemofreviving.item.totem.IronTotemItem;
|
||||||
import dev.micle.totemofreviving.item.totem.NetheriteTotemItem;
|
import dev.micle.totemofreviving.item.totem.NetheriteTotemItem;
|
||||||
import dev.micle.totemofreviving.item.totem.StrawTotemItem;
|
import dev.micle.totemofreviving.item.totem.StrawTotemItem;
|
||||||
import net.minecraftforge.common.ForgeConfigSpec;
|
import net.neoforged.fml.ModContainer;
|
||||||
import net.minecraftforge.fml.ModLoadingContext;
|
import net.neoforged.fml.config.ModConfig;
|
||||||
import net.minecraftforge.fml.config.ModConfig;
|
import net.neoforged.neoforge.common.ModConfigSpec;
|
||||||
|
|
||||||
public final class Config {
|
public final class Config {
|
||||||
public static void init() {
|
public static void init(ModContainer modContainer) {
|
||||||
ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, Server.SPEC);
|
modContainer.registerConfig(ModConfig.Type.SERVER, Server.SPEC);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Server {
|
public static class Server {
|
||||||
private static final ForgeConfigSpec SPEC;
|
private static final ModConfigSpec SPEC;
|
||||||
|
|
||||||
private static final TotemConfig STRAW_TOTEM_CONFIG;
|
private static final TotemConfig STRAW_TOTEM_CONFIG;
|
||||||
private static final TotemConfig IRON_TOTEM_CONFIG;
|
private static final TotemConfig IRON_TOTEM_CONFIG;
|
||||||
@ -22,7 +22,7 @@ public final class Config {
|
|||||||
private static final TotemConfig NETHERITE_TOTEM_CONFIG;
|
private static final TotemConfig NETHERITE_TOTEM_CONFIG;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder();
|
ModConfigSpec.Builder builder = new ModConfigSpec.Builder();
|
||||||
|
|
||||||
builder.comment("WHEN MAKING CHANGES IT IS RECOMMENDED TO NOT BE IN A WORLD.\n" +
|
builder.comment("WHEN MAKING CHANGES IT IS RECOMMENDED TO NOT BE IN A WORLD.\n" +
|
||||||
"CHANGES WILL MOST LIKELY REQUIRE A RESTART FOR EVERYTHING TO WORK PROPERLY.");
|
"CHANGES WILL MOST LIKELY REQUIRE A RESTART FOR EVERYTHING TO WORK PROPERLY.");
|
||||||
@ -45,14 +45,14 @@ public final class Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class TotemConfig {
|
public static class TotemConfig {
|
||||||
private final ForgeConfigSpec.IntValue CHARGE_COST;
|
private final ModConfigSpec.IntValue CHARGE_COST;
|
||||||
private final ForgeConfigSpec.IntValue CHARGE_COST_LIMIT;
|
private final ModConfigSpec.IntValue CHARGE_COST_LIMIT;
|
||||||
private final ForgeConfigSpec.DoubleValue CHARGE_COST_MULTIPLIER;
|
private final ModConfigSpec.DoubleValue CHARGE_COST_MULTIPLIER;
|
||||||
private final ForgeConfigSpec.BooleanValue CAN_REVIVE_MORE_EXPENSIVE_TARGETS;
|
private final ModConfigSpec.BooleanValue CAN_REVIVE_MORE_EXPENSIVE_TARGETS;
|
||||||
private final ForgeConfigSpec.BooleanValue CAN_REVIVE_ACROSS_DIMENSIONS;
|
private final ModConfigSpec.BooleanValue CAN_REVIVE_ACROSS_DIMENSIONS;
|
||||||
private final ForgeConfigSpec.IntValue DURABILITY;
|
private final ModConfigSpec.IntValue DURABILITY;
|
||||||
|
|
||||||
public TotemConfig(ForgeConfigSpec.Builder builder, String name, int chargeCost,
|
public TotemConfig(ModConfigSpec.Builder builder, String name, int chargeCost,
|
||||||
int chargeCostLimit, double chargeCostMultiplier, boolean canReviveMoreExpensiveTargets,
|
int chargeCostLimit, double chargeCostMultiplier, boolean canReviveMoreExpensiveTargets,
|
||||||
boolean canReviveAcrossDimensions, int durability) {
|
boolean canReviveAcrossDimensions, int durability) {
|
||||||
builder.push(name);
|
builder.push(name);
|
||||||
|
|||||||
Reference in New Issue
Block a user