From 4ba04c8e386a9e9b3ede88f8829733d09211ba02 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 --- .../terrablender/TerrablenderCompatInitializer.java | 9 ++++++++- 1 file changed, 8 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 69a3d6a2..9016038c 100644 --- a/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/terrablender/TerrablenderCompatInitializer.java +++ b/src/main/java/org/cyclops/integrateddynamicscompat/modcompat/terrablender/TerrablenderCompatInitializer.java @@ -1,9 +1,11 @@ package org.cyclops.integrateddynamicscompat.modcompat.terrablender; import net.minecraft.resources.ResourceLocation; +import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent; import org.cyclops.cyclopscore.modcompat.ICompatInitializer; import org.cyclops.integrateddynamics.Reference; import org.cyclops.integrateddynamicscompat.GeneralConfig; +import org.cyclops.integrateddynamicscompat.IntegratedDynamicsCompat; import terrablender.api.Regions; /** @@ -13,7 +15,12 @@ public class TerrablenderCompatInitializer implements ICompatInitializer { @Override public void initialize() { if (GeneralConfig.meneglinBiomeSpawnWeight > 0) { - Regions.register(new TestRegion(ResourceLocation.fromNamespaceAndPath(Reference.MOD_ID, "overworld"), GeneralConfig.meneglinBiomeSpawnWeight)); + IntegratedDynamicsCompat._instance.getModEventBus().addListener(this::commonSetup); } } + + private void commonSetup(final FMLCommonSetupEvent event) { + event.enqueueWork(() -> Regions + .register(new TestRegion(ResourceLocation.fromNamespaceAndPath(Reference.MOD_ID, "overworld"), GeneralConfig.meneglinBiomeSpawnWeight))); + } }