Skip to content

Commit

Permalink
Fix NeoForge startup crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
Juuxel committed Aug 7, 2024
1 parent 0ec852a commit 8b05067
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
28 changes: 15 additions & 13 deletions common/src/main/java/juuxel/adorn/lib/AdornStats.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,27 @@

public final class AdornStats {
public static final Registrar<Identifier> 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);
}
}
}
4 changes: 2 additions & 2 deletions forge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
1 change: 1 addition & 0 deletions forge/src/main/java/juuxel/adorn/platform/forge/Adorn.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

0 comments on commit 8b05067

Please sign in to comment.