diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/WorldGenerationStep.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/WorldGenerationStep.java index afd905e2a..755aaf206 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/WorldGenerationStep.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/WorldGenerationStep.java @@ -1071,14 +1071,20 @@ public final class WorldGenerationStep { final LightGenerationMode lightMode; final EmptyChunkGenerator generator; final int writeRadius; + final int size; + private final ChunkPos firstPos; + private final List cache; Long2ObjectOpenHashMap chunkMap = new Long2ObjectOpenHashMap(); public LightedWorldGenRegion(ServerLevel serverLevel, WorldGenLevelLightEngine lightEngine, List list, ChunkStatus chunkStatus, int i, LightGenerationMode lightMode, EmptyChunkGenerator generator) { super(serverLevel, list, chunkStatus, i); this.lightMode = lightMode; + this.firstPos = list.get(0).getPos(); this.generator = generator; light = lightEngine; writeRadius = i; + cache = list; + size = Mth.floor(Math.sqrt(list.size())); } // Bypass BCLib mixin overrides. @@ -1156,12 +1162,25 @@ public final class WorldGenerationStep { return this.getChunk(i, j, chunkStatus, true); } + // Use this instead of super.getChunk() to bypass C2ME concurrency checks + private ChunkAccess superGetChunk(int x, int z, ChunkStatus cs) { + int k = x - firstPos.x; + int l = z - firstPos.z; + return cache.get(k + l * size); + } + // Use this instead of super.hasChunk() to bypass C2ME concurrency checks + private boolean superHasChunk(int x, int z) { + int k = x - firstPos.x; + int l = z - firstPos.z; + return l>=0 && l=0 && k