From 8b05067f8283d24e268c1e7a818933211b0edc38 Mon Sep 17 00:00:00 2001 From: Juuz <6596629+Juuxel@users.noreply.github.com> Date: Wed, 7 Aug 2024 23:24:12 +0300 Subject: [PATCH] Fix NeoForge startup crashes --- .../java/juuxel/adorn/lib/AdornStats.java | 28 ++++++++++--------- forge/build.gradle.kts | 4 +-- .../juuxel/adorn/platform/forge/Adorn.java | 1 + 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/common/src/main/java/juuxel/adorn/lib/AdornStats.java b/common/src/main/java/juuxel/adorn/lib/AdornStats.java index 31ea203e8..733da403f 100644 --- a/common/src/main/java/juuxel/adorn/lib/AdornStats.java +++ b/common/src/main/java/juuxel/adorn/lib/AdornStats.java @@ -10,25 +10,27 @@ public final class AdornStats { public static final Registrar CUSTOM_STATS = RegistrarFactory.get().create(RegistryKeys.CUSTOM_STAT); - public static final Identifier OPEN_BREWER = register("open_brewer", StatFormatter.DEFAULT); - public static final Identifier OPEN_DRAWER = register("open_drawer", StatFormatter.DEFAULT); - public static final Identifier OPEN_KITCHEN_CUPBOARD = register("open_kitchen_cupboard", StatFormatter.DEFAULT); - public static final Identifier INTERACT_WITH_SHELF = register("interact_with_shelf", StatFormatter.DEFAULT); - public static final Identifier INTERACT_WITH_TABLE_LAMP = register("interact_with_table_lamp", StatFormatter.DEFAULT); - public static final Identifier INTERACT_WITH_TRADING_STATION = register("interact_with_trading_station", StatFormatter.DEFAULT); - public static final Identifier DYE_TABLE_LAMP = register("dye_table_lamp", StatFormatter.DEFAULT); - public static final Identifier DYE_SOFA = register("dye_sofa", StatFormatter.DEFAULT); - public static final Identifier SIT_ON_CHAIR = register("sit_on_chair", StatFormatter.DEFAULT); - public static final Identifier SIT_ON_SOFA = register("sit_on_sofa", StatFormatter.DEFAULT); - public static final Identifier SIT_ON_BENCH = register("sit_on_bench", StatFormatter.DEFAULT); + public static final Identifier OPEN_BREWER = register("open_brewer"); + public static final Identifier OPEN_DRAWER = register("open_drawer"); + public static final Identifier OPEN_KITCHEN_CUPBOARD = register("open_kitchen_cupboard"); + public static final Identifier INTERACT_WITH_SHELF = register("interact_with_shelf"); + public static final Identifier INTERACT_WITH_TABLE_LAMP = register("interact_with_table_lamp"); + public static final Identifier INTERACT_WITH_TRADING_STATION = register("interact_with_trading_station"); + public static final Identifier DYE_TABLE_LAMP = register("dye_table_lamp"); + public static final Identifier DYE_SOFA = register("dye_sofa"); + public static final Identifier SIT_ON_CHAIR = register("sit_on_chair"); + public static final Identifier SIT_ON_SOFA = register("sit_on_sofa"); + public static final Identifier SIT_ON_BENCH = register("sit_on_bench"); - private static Identifier register(String name, StatFormatter formatter) { + private static Identifier register(String name) { var id = AdornCommon.id(name); CUSTOM_STATS.register(name, () -> id); - Stats.CUSTOM.getOrCreateStat(id, formatter); return id; } public static void init() { + for (Identifier stat : CUSTOM_STATS) { + Stats.CUSTOM.getOrCreateStat(stat, StatFormatter.DEFAULT); + } } } diff --git a/forge/build.gradle.kts b/forge/build.gradle.kts index 6faf3a255..d0324fe05 100644 --- a/forge/build.gradle.kts +++ b/forge/build.gradle.kts @@ -54,8 +54,8 @@ tasks { // and should reset when the project version changes. inputs.property("version", project.version) - // Replace the $version template in mods.toml with the project version. - filesMatching("META-INF/mods.toml") { + // Replace the $version template in neoforge.mods.toml with the project version. + filesMatching("META-INF/neoforge.mods.toml") { expand("version" to project.version) } } diff --git a/forge/src/main/java/juuxel/adorn/platform/forge/Adorn.java b/forge/src/main/java/juuxel/adorn/platform/forge/Adorn.java index 850d20e40..c24404ede 100644 --- a/forge/src/main/java/juuxel/adorn/platform/forge/Adorn.java +++ b/forge/src/main/java/juuxel/adorn/platform/forge/Adorn.java @@ -79,6 +79,7 @@ private void register(Registrar registrar, IEventBus modBus) { private void init(FMLCommonSetupEvent event) { AdornGameRules.init(); AdornTags.init(); + AdornStats.init(); ConfigManager.get().finish(); } }