diff --git a/Common/src/main/java/at/petrak/hexcasting/common/misc/AkashicTreeGrower.java b/Common/src/main/java/at/petrak/hexcasting/common/misc/AkashicTreeGrower.java index 71f56cdc..9cba2f06 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/misc/AkashicTreeGrower.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/misc/AkashicTreeGrower.java @@ -26,7 +26,8 @@ public class AkashicTreeGrower extends AbstractTreeGrower { public static final List>> GROWERS = Lists.newArrayList(); - static { + public void RegisterTreeGrowers() + { GROWERS.add(buildTreeFeature(HexBlocks.AKASHIC_LEAVES1, "1")); GROWERS.add(buildTreeFeature(HexBlocks.AKASHIC_LEAVES2, "2")); GROWERS.add(buildTreeFeature(HexBlocks.AKASHIC_LEAVES3, "3")); diff --git a/Fabric/src/main/java/at/petrak/hexcasting/fabric/FabricHexInitializer.kt b/Fabric/src/main/java/at/petrak/hexcasting/fabric/FabricHexInitializer.kt index d2617383..b0a8325f 100644 --- a/Fabric/src/main/java/at/petrak/hexcasting/fabric/FabricHexInitializer.kt +++ b/Fabric/src/main/java/at/petrak/hexcasting/fabric/FabricHexInitializer.kt @@ -100,7 +100,10 @@ object FabricHexInitializer : ModInitializer { HexLootFunctions.registerSerializers(bind(Registry.LOOT_FUNCTION_TYPE)) - AkashicTreeGrower.INSTANCE + // Because of Java's lazy-loading of classes, can't use Kotlin static initialization for + // any calls that will eventually touch FeatureUtils.register(), as the growers here do, + // unless the class is called in this initialization step. + AkashicTreeGrower.INSTANCE.RegisterTreeGrowers() // Done with soft implements in forge val flameOn = FlammableBlockRegistry.getDefaultInstance() diff --git a/Forge/src/main/java/at/petrak/hexcasting/forge/ForgeHexInitializer.java b/Forge/src/main/java/at/petrak/hexcasting/forge/ForgeHexInitializer.java index e1a281ca..4df82313 100644 --- a/Forge/src/main/java/at/petrak/hexcasting/forge/ForgeHexInitializer.java +++ b/Forge/src/main/java/at/petrak/hexcasting/forge/ForgeHexInitializer.java @@ -14,6 +14,7 @@ import at.petrak.hexcasting.common.entities.HexEntities; import at.petrak.hexcasting.common.items.ItemJewelerHammer; import at.petrak.hexcasting.common.lib.*; import at.petrak.hexcasting.common.loot.HexLootHandler; +import at.petrak.hexcasting.common.misc.AkashicTreeGrower; import at.petrak.hexcasting.common.misc.Brainsweeping; import at.petrak.hexcasting.common.misc.PlayerPositionRecorder; import at.petrak.hexcasting.common.recipe.HexRecipeSerializers; @@ -104,6 +105,11 @@ public class ForgeHexInitializer { ArgumentTypes.register(HexAPI.MOD_ID + ":pattern", PatternResLocArgument.class, new EmptyArgumentSerializer<>(PatternResLocArgument::id)); HexAdvancementTriggers.registerTriggers(); + + // Forge does not strictly require TreeGrowers to initialize during early game stages, unlike Fabric and Quilt. + // However, all launcher panic if the same resource is registered twice. Explicitly calling here avoids potential + // confusion, or reliance on tricks that may fail under compiler optimization. + AkashicTreeGrower.INSTANCE.RegisterTreeGrowers(); } // https://github.com/VazkiiMods/Botania/blob/1.18.x/Forge/src/main/java/vazkii/botania/forge/ForgeCommonInitializer.java