From 2eed0295e6112161f6a8f18f523455d0000fbedd Mon Sep 17 00:00:00 2001 From: Ruben Taelman Date: Sat, 24 Aug 2024 07:13:05 +0200 Subject: [PATCH] Delay Terrablender registration This fixes rare crashes when Terrablender was not yet fully initialized. CyclopsMC/IntegratedDynamics#1385 Closes CyclopsMC/IntegratedDynamics#1388 --- .../terrablender/TerrablenderCompatInitializer.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/terrablender/TerrablenderCompatInitializer.java b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/terrablender/TerrablenderCompatInitializer.java index 78338af..a42e4c8 100644 --- a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/terrablender/TerrablenderCompatInitializer.java +++ b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/terrablender/TerrablenderCompatInitializer.java @@ -1,6 +1,8 @@ package org.cyclops.integrateddynamicscompat.modcompat.terrablender; import net.minecraft.resources.ResourceLocation; +import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; +import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.cyclops.cyclopscore.modcompat.ICompatInitializer; import org.cyclops.integrateddynamics.Reference; import org.cyclops.integrateddynamics.world.biome.BiomeMeneglinConfig; @@ -13,7 +15,11 @@ public class TerrablenderCompatInitializer implements ICompatInitializer { @Override public void initialize() { if (BiomeMeneglinConfig.spawnWeight > 0) { - Regions.register(new TestRegion(new ResourceLocation(Reference.MOD_ID, "overworld"), BiomeMeneglinConfig.spawnWeight)); + FMLJavaModLoadingContext.get().getModEventBus().addListener(this::commonSetup); } } + + private void commonSetup(final FMLCommonSetupEvent event) { + event.enqueueWork(() -> Regions.register(new TestRegion(new ResourceLocation(Reference.MOD_ID, "overworld"), BiomeMeneglinConfig.spawnWeight))); + } }