Fix loadChunk try/catch missing the mark & add WRAN on modded chunkGen

This commit is contained in:
tom lee
2022-02-12 13:11:48 +08:00
parent b3af6df0c5
commit 332df13b29
2 changed files with 18 additions and 1 deletions
@@ -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);
}
}
}
@@ -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();
}