From 2262cc59529e1c785969826c2c46bfaaf796bc9d Mon Sep 17 00:00:00 2001 From: micle Date: Fri, 9 Jan 2026 00:37:25 +0100 Subject: [PATCH] Ported config. --- .../totemofreviving/TotemOfReviving.java | 6 ++-- .../micle/totemofreviving/proxy/Proxy.java | 13 +++++---- .../micle/totemofreviving/setup/Config.java | 28 +++++++++---------- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/main/java/dev/micle/totemofreviving/TotemOfReviving.java b/src/main/java/dev/micle/totemofreviving/TotemOfReviving.java index 69b1821..4ae6bda 100644 --- a/src/main/java/dev/micle/totemofreviving/TotemOfReviving.java +++ b/src/main/java/dev/micle/totemofreviving/TotemOfReviving.java @@ -18,10 +18,10 @@ public final class TotemOfReviving { private static IProxy proxy; - public TotemOfReviving(IEventBus modEventBus) { + public TotemOfReviving(IEventBus modEventBus, ModContainer modContainer) { proxy = FMLEnvironment.dist == Dist.CLIENT - ? new Proxy.Client(modEventBus) - : new Proxy.Server(modEventBus); + ? new Proxy.Client(modEventBus, modContainer) + : new Proxy.Server(modEventBus, modContainer); } public static ResourceLocation createResourceLocation(String name) { diff --git a/src/main/java/dev/micle/totemofreviving/proxy/Proxy.java b/src/main/java/dev/micle/totemofreviving/proxy/Proxy.java index 939677d..fc60fdf 100644 --- a/src/main/java/dev/micle/totemofreviving/proxy/Proxy.java +++ b/src/main/java/dev/micle/totemofreviving/proxy/Proxy.java @@ -10,6 +10,7 @@ import net.minecraft.world.level.Level; import net.neoforged.api.distmarker.Dist; import net.neoforged.api.distmarker.OnlyIn; import net.neoforged.bus.api.IEventBus; +import net.neoforged.fml.ModContainer; import net.neoforged.fml.event.lifecycle.*; import net.neoforged.neoforge.common.NeoForge; import net.neoforged.neoforge.event.AddReloadListenerEvent; @@ -21,10 +22,10 @@ public class Proxy implements IProxy { private static MinecraftServer server = null; // Common setup - public Proxy(IEventBus modEventBus) { + public Proxy(IEventBus modEventBus, ModContainer modContainer) { // Initialize setup Registration.register(); - Config.init(); + Config.init(modContainer); NetworkManager.init(); // Register mod event bus listeners @@ -71,8 +72,8 @@ public class Proxy implements IProxy { // Client setup public static class Client extends Proxy { - public Client(IEventBus modEventBus) { - super(modEventBus); + public Client(IEventBus modEventBus, ModContainer modContainer) { + super(modEventBus, modContainer); // Register mod event bus listeners modEventBus.addListener(Client::setup); modEventBus.addListener(Client::postSetup); @@ -97,8 +98,8 @@ public class Proxy implements IProxy { // Server setup public static class Server extends Proxy { - public Server(IEventBus modEventBus) { - super(modEventBus); + public Server(IEventBus modEventBus, ModContainer modContainer) { + super(modEventBus, modContainer); // Register mod event bus listeners modEventBus.addListener(Server::setup); } diff --git a/src/main/java/dev/micle/totemofreviving/setup/Config.java b/src/main/java/dev/micle/totemofreviving/setup/Config.java index 9be35c4..9c19840 100644 --- a/src/main/java/dev/micle/totemofreviving/setup/Config.java +++ b/src/main/java/dev/micle/totemofreviving/setup/Config.java @@ -4,17 +4,17 @@ import dev.micle.totemofreviving.item.totem.DiamondTotemItem; import dev.micle.totemofreviving.item.totem.IronTotemItem; import dev.micle.totemofreviving.item.totem.NetheriteTotemItem; import dev.micle.totemofreviving.item.totem.StrawTotemItem; -import net.minecraftforge.common.ForgeConfigSpec; -import net.minecraftforge.fml.ModLoadingContext; -import net.minecraftforge.fml.config.ModConfig; +import net.neoforged.fml.ModContainer; +import net.neoforged.fml.config.ModConfig; +import net.neoforged.neoforge.common.ModConfigSpec; public final class Config { - public static void init() { - ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, Server.SPEC); + public static void init(ModContainer modContainer) { + modContainer.registerConfig(ModConfig.Type.SERVER, Server.SPEC); } 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 IRON_TOTEM_CONFIG; @@ -22,7 +22,7 @@ public final class Config { private static final TotemConfig NETHERITE_TOTEM_CONFIG; 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" + "CHANGES WILL MOST LIKELY REQUIRE A RESTART FOR EVERYTHING TO WORK PROPERLY."); @@ -45,14 +45,14 @@ public final class Config { } public static class TotemConfig { - private final ForgeConfigSpec.IntValue CHARGE_COST; - private final ForgeConfigSpec.IntValue CHARGE_COST_LIMIT; - private final ForgeConfigSpec.DoubleValue CHARGE_COST_MULTIPLIER; - private final ForgeConfigSpec.BooleanValue CAN_REVIVE_MORE_EXPENSIVE_TARGETS; - private final ForgeConfigSpec.BooleanValue CAN_REVIVE_ACROSS_DIMENSIONS; - private final ForgeConfigSpec.IntValue DURABILITY; + private final ModConfigSpec.IntValue CHARGE_COST; + private final ModConfigSpec.IntValue CHARGE_COST_LIMIT; + private final ModConfigSpec.DoubleValue CHARGE_COST_MULTIPLIER; + private final ModConfigSpec.BooleanValue CAN_REVIVE_MORE_EXPENSIVE_TARGETS; + private final ModConfigSpec.BooleanValue CAN_REVIVE_ACROSS_DIMENSIONS; + 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, boolean canReviveAcrossDimensions, int durability) { builder.push(name);