diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java index 4590cda2b..cd3bb8fea 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java @@ -315,7 +315,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv { chunkData = level.getChunkSource().chunkMap.readChunk(chunkPos); } - catch (IOException e) + catch (Exception e) { ClientApi.LOGGER.error("DistantHorizons: Couldn't load chunk {}", chunkPos, e); } @@ -325,7 +325,12 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv } else { + try { return ChunkLoader.read(level, lightEngine, chunkPos, chunkData); + } catch (Exception e) { + ClientApi.LOGGER.error("DistantHorizons: Couldn't load chunk {}", chunkPos, e); + return new ProtoChunk(chunkPos, UpgradeData.EMPTY, level, level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), null); + } } } diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/GlobalParameters.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/GlobalParameters.java index 9d604028b..e20cb6c31 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/GlobalParameters.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/GlobalParameters.java @@ -4,6 +4,8 @@ package com.seibel.lod.common.wrappers.worldGeneration; import com.mojang.datafixers.DataFixer; import com.seibel.lod.core.builders.lodBuilding.LodBuilder; import com.seibel.lod.core.objects.lod.LodDimension; +import com.seibel.lod.core.util.SingletonHandler; +import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftWrapper; import net.minecraft.core.Registry; import net.minecraft.core.RegistryAccess; @@ -14,6 +16,9 @@ import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.biome.BiomeManager; import net.minecraft.world.level.chunk.ChunkGenerator; import net.minecraft.world.level.chunk.storage.ChunkScanAccess; +import net.minecraft.world.level.levelgen.DebugLevelSource; +import net.minecraft.world.level.levelgen.FlatLevelSource; +import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator; import net.minecraft.world.level.levelgen.WorldGenSettings; import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager; import net.minecraft.world.level.storage.WorldData; @@ -33,6 +38,7 @@ public final class GlobalParameters public final ChunkScanAccess chunkScanner; public final ServerLevel level; // TODO: Figure out a way to remove this. Maybe ClientLevel also works? public final DataFixer fixerUpper; + private static final IMinecraftWrapper MC = SingletonHandler.get(IMinecraftWrapper.class); public GlobalParameters(ServerLevel level, LodBuilder lodBuilder, LodDimension lodDim) { @@ -49,6 +55,12 @@ public final class GlobalParameters biomeManager = new BiomeManager(level, BiomeManager.obfuscateSeed(worldSeed)); structures = server.getStructureManager(); generator = level.getChunkSource().getGenerator(); + if (!(generator instanceof NoiseBasedChunkGenerator || + generator instanceof DebugLevelSource || + generator instanceof FlatLevelSource)) { + MC.sendChatMessage("&4&l&uWARNING: Unknown Chunk Generator Detected! Distant Generation May Fail!"); + MC.sendChatMessage("&eIf it does crash, set Distant Generation to OFF or Generation Mode to None."); + } chunkScanner = level.getChunkSource().chunkScanner(); fixerUpper = server.getFixerUpper(); }