--- a/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
+++ b/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
@@ -1,3 +1,4 @@
+// keep
 package net.minecraft.world.level.levelgen;
 
 import com.google.common.annotations.VisibleForTesting;
@@ -5,7 +6,9 @@
 import com.mojang.serialization.Codec;
 import com.mojang.serialization.codecs.RecordCodecBuilder;
 import java.text.DecimalFormat;
+import java.util.Iterator;
 import java.util.List;
+import java.util.Objects;
 import java.util.Optional;
 import java.util.OptionalInt;
 import java.util.Set;
@@ -49,13 +52,14 @@
 import org.apache.commons.lang3.mutable.MutableObject;
 
 public final class NoiseBasedChunkGenerator extends ChunkGenerator {
+
     public static final Codec<NoiseBasedChunkGenerator> CODEC = RecordCodecBuilder.create((instance) -> {
-        return commonCodec(instance).and(instance.group(RegistryOps.retrieveRegistry(Registry.NOISE_REGISTRY).forGetter((generator) -> {
-            return generator.noises;
-        }), BiomeSource.CODEC.fieldOf("biome_source").forGetter((generator) -> {
-            return generator.biomeSource;
-        }), NoiseGeneratorSettings.CODEC.fieldOf("settings").forGetter((generator) -> {
-            return generator.settings;
+        return commonCodec(instance).and(instance.group(RegistryOps.retrieveRegistry(Registry.NOISE_REGISTRY).forGetter((chunkgeneratorabstract) -> {
+            return chunkgeneratorabstract.noises;
+        }), BiomeSource.CODEC.fieldOf("biome_source").forGetter((chunkgeneratorabstract) -> {
+            return chunkgeneratorabstract.biomeSource;
+        }), NoiseGeneratorSettings.CODEC.fieldOf("settings").forGetter((chunkgeneratorabstract) -> {
+            return chunkgeneratorabstract.settings;
         }))).apply(instance, instance.stable(NoiseBasedChunkGenerator::new));
     });
     private static final BlockState AIR = Blocks.AIR.defaultBlockState();
@@ -68,14 +72,16 @@
         super(structureSetRegistry, Optional.empty(), populationSource);
         this.noises = noiseRegistry;
         this.settings = settings;
-        NoiseGeneratorSettings noiseGeneratorSettings = this.settings.value();
-        this.defaultBlock = noiseGeneratorSettings.defaultBlock();
-        Aquifer.FluidStatus fluidStatus = new Aquifer.FluidStatus(-54, Blocks.LAVA.defaultBlockState());
-        int i = noiseGeneratorSettings.seaLevel();
-        Aquifer.FluidStatus fluidStatus2 = new Aquifer.FluidStatus(i, noiseGeneratorSettings.defaultFluid());
-        Aquifer.FluidStatus fluidStatus3 = new Aquifer.FluidStatus(DimensionType.MIN_Y * 2, Blocks.AIR.defaultBlockState());
-        this.globalFluidPicker = (x, y, z) -> {
-            return y < Math.min(-54, i) ? fluidStatus : fluidStatus2;
+        NoiseGeneratorSettings generatorsettingbase = (NoiseGeneratorSettings) this.settings.value();
+
+        this.defaultBlock = generatorsettingbase.defaultBlock();
+        Aquifer.FluidStatus aquifer_b = new Aquifer.FluidStatus(-54, Blocks.LAVA.defaultBlockState());
+        int i = generatorsettingbase.seaLevel();
+        Aquifer.FluidStatus aquifer_b1 = new Aquifer.FluidStatus(i, generatorsettingbase.defaultFluid());
+        Aquifer.FluidStatus aquifer_b2 = new Aquifer.FluidStatus(DimensionType.MIN_Y * 2, Blocks.AIR.defaultBlockState());
+
+        this.globalFluidPicker = (j, k, l) -> {
+            return k < Math.min(-54, i) ? aquifer_b : aquifer_b1;
         };
     }
 
@@ -88,20 +94,21 @@
     }
 
     private void doCreateBiomes(Blender blender, RandomState noiseConfig, StructureManager structureAccessor, ChunkAccess chunk) {
-        NoiseChunk noiseChunk = chunk.getOrCreateNoiseChunk((chunkx) -> {
-            return this.createNoiseChunk(chunkx, structureAccessor, blender, noiseConfig);
+        NoiseChunk noisechunk = chunk.getOrCreateNoiseChunk((ichunkaccess1) -> {
+            return this.createNoiseChunk(ichunkaccess1, structureAccessor, blender, noiseConfig);
         });
-        BiomeResolver biomeResolver = BelowZeroRetrogen.getBiomeResolver(blender.getBiomeResolver(this.biomeSource), chunk);
-        chunk.fillBiomesFromNoise(biomeResolver, noiseChunk.cachedClimateSampler(noiseConfig.router(), this.settings.value().spawnTarget()));
+        BiomeResolver biomeresolver = BelowZeroRetrogen.getBiomeResolver(blender.getBiomeResolver(this.biomeSource), chunk);
+
+        chunk.fillBiomesFromNoise(biomeresolver, noisechunk.cachedClimateSampler(noiseConfig.router(), ((NoiseGeneratorSettings) this.settings.value()).spawnTarget()));
     }
 
     private NoiseChunk createNoiseChunk(ChunkAccess chunk, StructureManager world, Blender blender, RandomState noiseConfig) {
-        return NoiseChunk.forChunk(chunk, noiseConfig, Beardifier.forStructuresInChunk(world, chunk.getPos()), this.settings.value(), this.globalFluidPicker, blender);
+        return NoiseChunk.forChunk(chunk, noiseConfig, Beardifier.forStructuresInChunk(world, chunk.getPos()), (NoiseGeneratorSettings) this.settings.value(), this.globalFluidPicker, blender);
     }
 
     @Override
     protected Codec<? extends ChunkGenerator> codec() {
-        return CODEC;
+        return NoiseBasedChunkGenerator.CODEC;
     }
 
     public Holder<NoiseGeneratorSettings> generatorSettings() {
@@ -114,79 +121,88 @@
 
     @Override
     public int getBaseHeight(int x, int z, Heightmap.Types heightmap, LevelHeightAccessor world, RandomState noiseConfig) {
-        return this.iterateNoiseColumn(world, noiseConfig, x, z, (MutableObject<NoiseColumn>)null, heightmap.isOpaque()).orElse(world.getMinBuildHeight());
+        return this.iterateNoiseColumn(world, noiseConfig, x, z, (MutableObject) null, heightmap.isOpaque()).orElse(world.getMinBuildHeight());
     }
 
     @Override
     public NoiseColumn getBaseColumn(int x, int z, LevelHeightAccessor world, RandomState noiseConfig) {
-        MutableObject<NoiseColumn> mutableObject = new MutableObject<>();
-        this.iterateNoiseColumn(world, noiseConfig, x, z, mutableObject, (Predicate<BlockState>)null);
-        return mutableObject.getValue();
+        MutableObject<NoiseColumn> mutableobject = new MutableObject();
+
+        this.iterateNoiseColumn(world, noiseConfig, x, z, mutableobject, (Predicate) null);
+        return (NoiseColumn) mutableobject.getValue();
     }
 
     @Override
     public void addDebugScreenInfo(List<String> text, RandomState noiseConfig, BlockPos pos) {
-        DecimalFormat decimalFormat = new DecimalFormat("0.000");
-        NoiseRouter noiseRouter = noiseConfig.router();
-        DensityFunction.SinglePointContext singlePointContext = new DensityFunction.SinglePointContext(pos.getX(), pos.getY(), pos.getZ());
-        double d = noiseRouter.ridges().compute(singlePointContext);
-        text.add("NoiseRouter T: " + decimalFormat.format(noiseRouter.temperature().compute(singlePointContext)) + " V: " + decimalFormat.format(noiseRouter.vegetation().compute(singlePointContext)) + " C: " + decimalFormat.format(noiseRouter.continents().compute(singlePointContext)) + " E: " + decimalFormat.format(noiseRouter.erosion().compute(singlePointContext)) + " D: " + decimalFormat.format(noiseRouter.depth().compute(singlePointContext)) + " W: " + decimalFormat.format(d) + " PV: " + decimalFormat.format((double)NoiseRouterData.peaksAndValleys((float)d)) + " AS: " + decimalFormat.format(noiseRouter.initialDensityWithoutJaggedness().compute(singlePointContext)) + " N: " + decimalFormat.format(noiseRouter.finalDensity().compute(singlePointContext)));
+        DecimalFormat decimalformat = new DecimalFormat("0.000");
+        NoiseRouter noiserouter = noiseConfig.router();
+        DensityFunction.SinglePointContext densityfunction_e = new DensityFunction.SinglePointContext(pos.getX(), pos.getY(), pos.getZ());
+        double d0 = noiserouter.ridges().compute(densityfunction_e);
+        String s = decimalformat.format(noiserouter.temperature().compute(densityfunction_e));
+
+        text.add("NoiseRouter T: " + s + " V: " + decimalformat.format(noiserouter.vegetation().compute(densityfunction_e)) + " C: " + decimalformat.format(noiserouter.continents().compute(densityfunction_e)) + " E: " + decimalformat.format(noiserouter.erosion().compute(densityfunction_e)) + " D: " + decimalformat.format(noiserouter.depth().compute(densityfunction_e)) + " W: " + decimalformat.format(d0) + " PV: " + decimalformat.format((double) NoiseRouterData.peaksAndValleys((float) d0)) + " AS: " + decimalformat.format(noiserouter.initialDensityWithoutJaggedness().compute(densityfunction_e)) + " N: " + decimalformat.format(noiserouter.finalDensity().compute(densityfunction_e)));
     }
 
     private OptionalInt iterateNoiseColumn(LevelHeightAccessor world, RandomState noiseConfig, int x, int z, @Nullable MutableObject<NoiseColumn> columnSample, @Nullable Predicate<BlockState> stopPredicate) {
-        NoiseSettings noiseSettings = this.settings.value().noiseSettings().clampToHeightAccessor(world);
-        int i = noiseSettings.getCellHeight();
-        int j = noiseSettings.minY();
-        int k = Mth.intFloorDiv(j, i);
-        int l = Mth.intFloorDiv(noiseSettings.height(), i);
-        if (l <= 0) {
+        NoiseSettings noisesettings = ((NoiseGeneratorSettings) this.settings.value()).noiseSettings().clampToHeightAccessor(world);
+        int k = noisesettings.getCellHeight();
+        int l = noisesettings.minY();
+        int i1 = Mth.intFloorDiv(l, k);
+        int j1 = Mth.intFloorDiv(noisesettings.height(), k);
+
+        if (j1 <= 0) {
             return OptionalInt.empty();
         } else {
-            BlockState[] blockStates;
+            BlockState[] aiblockdata;
+
             if (columnSample == null) {
-                blockStates = null;
+                aiblockdata = null;
             } else {
-                blockStates = new BlockState[noiseSettings.height()];
-                columnSample.setValue(new NoiseColumn(j, blockStates));
+                aiblockdata = new BlockState[noisesettings.height()];
+                columnSample.setValue(new NoiseColumn(l, aiblockdata));
             }
 
-            int m = noiseSettings.getCellWidth();
-            int n = Math.floorDiv(x, m);
-            int o = Math.floorDiv(z, m);
-            int p = Math.floorMod(x, m);
-            int q = Math.floorMod(z, m);
-            int r = n * m;
-            int s = o * m;
-            double d = (double)p / (double)m;
-            double e = (double)q / (double)m;
-            NoiseChunk noiseChunk = new NoiseChunk(1, noiseConfig, r, s, noiseSettings, DensityFunctions.BeardifierMarker.INSTANCE, this.settings.value(), this.globalFluidPicker, Blender.empty());
-            noiseChunk.initializeForFirstCellX();
-            noiseChunk.advanceCellX(0);
+            int k1 = noisesettings.getCellWidth();
+            int l1 = Math.floorDiv(x, k1);
+            int i2 = Math.floorDiv(z, k1);
+            int j2 = Math.floorMod(x, k1);
+            int k2 = Math.floorMod(z, k1);
+            int l2 = l1 * k1;
+            int i3 = i2 * k1;
+            double d0 = (double) j2 / (double) k1;
+            double d1 = (double) k2 / (double) k1;
+            NoiseChunk noisechunk = new NoiseChunk(1, noiseConfig, l2, i3, noisesettings, DensityFunctions.BeardifierMarker.INSTANCE, (NoiseGeneratorSettings) this.settings.value(), this.globalFluidPicker, Blender.empty());
 
-            for(int t = l - 1; t >= 0; --t) {
-                noiseChunk.selectCellYZ(t, 0);
+            noisechunk.initializeForFirstCellX();
+            noisechunk.advanceCellX(0);
 
-                for(int u = i - 1; u >= 0; --u) {
-                    int v = (k + t) * i + u;
-                    double f = (double)u / (double)i;
-                    noiseChunk.updateForY(v, f);
-                    noiseChunk.updateForX(x, d);
-                    noiseChunk.updateForZ(z, e);
-                    BlockState blockState = noiseChunk.getInterpolatedState();
-                    BlockState blockState2 = blockState == null ? this.defaultBlock : blockState;
-                    if (blockStates != null) {
-                        int w = t * i + u;
-                        blockStates[w] = blockState2;
+            for (int j3 = j1 - 1; j3 >= 0; --j3) {
+                noisechunk.selectCellYZ(j3, 0);
+
+                for (int k3 = k - 1; k3 >= 0; --k3) {
+                    int l3 = (i1 + j3) * k + k3;
+                    double d2 = (double) k3 / (double) k;
+
+                    noisechunk.updateForY(l3, d2);
+                    noisechunk.updateForX(x, d0);
+                    noisechunk.updateForZ(z, d1);
+                    BlockState iblockdata = noisechunk.getInterpolatedState();
+                    BlockState iblockdata1 = iblockdata == null ? this.defaultBlock : iblockdata;
+
+                    if (aiblockdata != null) {
+                        int i4 = j3 * k + k3;
+
+                        aiblockdata[i4] = iblockdata1;
                     }
 
-                    if (stopPredicate != null && stopPredicate.test(blockState2)) {
-                        noiseChunk.stopInterpolation();
-                        return OptionalInt.of(v + 1);
+                    if (stopPredicate != null && stopPredicate.test(iblockdata1)) {
+                        noisechunk.stopInterpolation();
+                        return OptionalInt.of(l3 + 1);
                     }
                 }
             }
 
-            noiseChunk.stopInterpolation();
+            noisechunk.stopInterpolation();
             return OptionalInt.empty();
         }
     }
@@ -194,53 +210,56 @@
     @Override
     public void buildSurface(WorldGenRegion region, StructureManager structures, RandomState noiseConfig, ChunkAccess chunk) {
         if (!SharedConstants.debugVoidTerrain(chunk.getPos())) {
-            WorldGenerationContext worldGenerationContext = new WorldGenerationContext(this, region);
-            this.buildSurface(chunk, worldGenerationContext, noiseConfig, structures, region.getBiomeManager(), region.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), Blender.of(region));
+            WorldGenerationContext worldgenerationcontext = new WorldGenerationContext(this, region, region.getMinecraftWorld()); // Paper
+
+            this.buildSurface(chunk, worldgenerationcontext, noiseConfig, structures, region.getBiomeManager(), region.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), Blender.of(region));
         }
     }
 
     @VisibleForTesting
     public void buildSurface(ChunkAccess chunk, WorldGenerationContext heightContext, RandomState noiseConfig, StructureManager structureAccessor, BiomeManager biomeAccess, Registry<Biome> biomeRegistry, Blender blender) {
-        NoiseChunk noiseChunk = chunk.getOrCreateNoiseChunk((chunkx) -> {
-            return this.createNoiseChunk(chunkx, structureAccessor, blender, noiseConfig);
+        NoiseChunk noisechunk = chunk.getOrCreateNoiseChunk((ichunkaccess1) -> {
+            return this.createNoiseChunk(ichunkaccess1, structureAccessor, blender, noiseConfig);
         });
-        NoiseGeneratorSettings noiseGeneratorSettings = this.settings.value();
-        noiseConfig.surfaceSystem().buildSurface(noiseConfig, biomeAccess, biomeRegistry, noiseGeneratorSettings.useLegacyRandomSource(), heightContext, chunk, noiseChunk, noiseGeneratorSettings.surfaceRule());
+        NoiseGeneratorSettings generatorsettingbase = (NoiseGeneratorSettings) this.settings.value();
+
+        noiseConfig.surfaceSystem().buildSurface(noiseConfig, biomeAccess, biomeRegistry, generatorsettingbase.useLegacyRandomSource(), heightContext, chunk, noisechunk, generatorsettingbase.surfaceRule());
     }
 
     @Override
     public void applyCarvers(WorldGenRegion chunkRegion, long seed, RandomState noiseConfig, BiomeManager biomeAccess, StructureManager structureAccessor, ChunkAccess chunk, GenerationStep.Carving carverStep) {
-        BiomeManager biomeManager = biomeAccess.withDifferentSource((biomeX, biomeY, biomeZ) -> {
-            return this.biomeSource.getNoiseBiome(biomeX, biomeY, biomeZ, noiseConfig.sampler());
+        BiomeManager biomemanager1 = biomeAccess.withDifferentSource((j, k, l) -> {
+            return this.biomeSource.getNoiseBiome(j, k, l, noiseConfig.sampler());
         });
-        WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(RandomSupport.generateUniqueSeed()));
-        int i = 8;
-        ChunkPos chunkPos = chunk.getPos();
-        NoiseChunk noiseChunk = chunk.getOrCreateNoiseChunk((chunkx) -> {
-            return this.createNoiseChunk(chunkx, structureAccessor, Blender.of(chunkRegion), noiseConfig);
+        WorldgenRandom seededrandom = new WorldgenRandom(new LegacyRandomSource(RandomSupport.generateUniqueSeed()));
+        boolean flag = true;
+        ChunkPos chunkcoordintpair = chunk.getPos();
+        NoiseChunk noisechunk = chunk.getOrCreateNoiseChunk((ichunkaccess1) -> {
+            return this.createNoiseChunk(ichunkaccess1, structureAccessor, Blender.of(chunkRegion), noiseConfig);
         });
-        Aquifer aquifer = noiseChunk.aquifer();
-        CarvingContext carvingContext = new CarvingContext(this, chunkRegion.registryAccess(), chunk.getHeightAccessorForGeneration(), noiseChunk, noiseConfig, this.settings.value().surfaceRule());
-        CarvingMask carvingMask = ((ProtoChunk)chunk).getOrCreateCarvingMask(carverStep);
+        Aquifer aquifer = noisechunk.aquifer();
+        CarvingContext carvingcontext = new CarvingContext(this, chunkRegion.registryAccess(), chunk.getHeightAccessorForGeneration(), noisechunk, noiseConfig, ((NoiseGeneratorSettings) this.settings.value()).surfaceRule(), chunkRegion.getMinecraftWorld()); // Paper
+        CarvingMask carvingmask = ((ProtoChunk) chunk).getOrCreateCarvingMask(carverStep);
 
-        for(int j = -8; j <= 8; ++j) {
-            for(int k = -8; k <= 8; ++k) {
-                ChunkPos chunkPos2 = new ChunkPos(chunkPos.x + j, chunkPos.z + k);
-                ChunkAccess chunkAccess = chunkRegion.getChunk(chunkPos2.x, chunkPos2.z);
-                BiomeGenerationSettings biomeGenerationSettings = chunkAccess.carverBiome(() -> {
-                    return this.getBiomeGenerationSettings(this.biomeSource.getNoiseBiome(QuartPos.fromBlock(chunkPos2.getMinBlockX()), 0, QuartPos.fromBlock(chunkPos2.getMinBlockZ()), noiseConfig.sampler()));
+        for (int j = -8; j <= 8; ++j) {
+            for (int k = -8; k <= 8; ++k) {
+                ChunkPos chunkcoordintpair1 = new ChunkPos(chunkcoordintpair.x + j, chunkcoordintpair.z + k);
+                ChunkAccess ichunkaccess1 = chunkRegion.getChunk(chunkcoordintpair1.x, chunkcoordintpair1.z);
+                BiomeGenerationSettings biomesettingsgeneration = ichunkaccess1.carverBiome(() -> {
+                    return this.getBiomeGenerationSettings(this.biomeSource.getNoiseBiome(QuartPos.fromBlock(chunkcoordintpair1.getMinBlockX()), 0, QuartPos.fromBlock(chunkcoordintpair1.getMinBlockZ()), noiseConfig.sampler()));
                 });
-                Iterable<Holder<ConfiguredWorldCarver<?>>> iterable = biomeGenerationSettings.getCarvers(carverStep);
+                Iterable<Holder<ConfiguredWorldCarver<?>>> iterable = biomesettingsgeneration.getCarvers(carverStep);
                 int l = 0;
 
-                for(Holder<ConfiguredWorldCarver<?>> holder : iterable) {
-                    ConfiguredWorldCarver<?> configuredWorldCarver = holder.value();
-                    worldgenRandom.setLargeFeatureSeed(seed + (long)l, chunkPos2.x, chunkPos2.z);
-                    if (configuredWorldCarver.isStartChunk(worldgenRandom)) {
-                        configuredWorldCarver.carve(carvingContext, chunk, biomeManager::getBiome, worldgenRandom, aquifer, chunkPos2, carvingMask);
-                    }
+                for (Iterator iterator = iterable.iterator(); iterator.hasNext(); ++l) {
+                    Holder<ConfiguredWorldCarver<?>> holder = (Holder) iterator.next();
+                    ConfiguredWorldCarver<?> worldgencarverwrapper = (ConfiguredWorldCarver) holder.value();
 
-                    ++l;
+                    seededrandom.setLargeFeatureSeed(seed + (long) l, chunkcoordintpair1.x, chunkcoordintpair1.z);
+                    if (worldgencarverwrapper.isStartChunk(seededrandom)) {
+                        Objects.requireNonNull(biomemanager1);
+                        worldgencarverwrapper.carve(carvingcontext, chunk, biomemanager1::getBiome, seededrandom, aquifer, chunkcoordintpair1, carvingmask);
+                    }
                 }
             }
         }
@@ -249,28 +268,34 @@
 
     @Override
     public CompletableFuture<ChunkAccess> fillFromNoise(Executor executor, Blender blender, RandomState noiseConfig, StructureManager structureAccessor, ChunkAccess chunk) {
-        NoiseSettings noiseSettings = this.settings.value().noiseSettings().clampToHeightAccessor(chunk.getHeightAccessorForGeneration());
-        int i = noiseSettings.minY();
-        int j = Mth.intFloorDiv(i, noiseSettings.getCellHeight());
-        int k = Mth.intFloorDiv(noiseSettings.height(), noiseSettings.getCellHeight());
+        NoiseSettings noisesettings = ((NoiseGeneratorSettings) this.settings.value()).noiseSettings().clampToHeightAccessor(chunk.getHeightAccessorForGeneration());
+        int i = noisesettings.minY();
+        int j = Mth.intFloorDiv(i, noisesettings.getCellHeight());
+        int k = Mth.intFloorDiv(noisesettings.height(), noisesettings.getCellHeight());
+
         if (k <= 0) {
             return CompletableFuture.completedFuture(chunk);
         } else {
-            int l = chunk.getSectionIndex(k * noiseSettings.getCellHeight() - 1 + i);
-            int m = chunk.getSectionIndex(i);
+            int l = chunk.getSectionIndex(k * noisesettings.getCellHeight() - 1 + i);
+            int i1 = chunk.getSectionIndex(i);
             Set<LevelChunkSection> set = Sets.newHashSet();
 
-            for(int n = l; n >= m; --n) {
-                LevelChunkSection levelChunkSection = chunk.getSection(n);
-                levelChunkSection.acquire();
-                set.add(levelChunkSection);
+            for (int j1 = l; j1 >= i1; --j1) {
+                LevelChunkSection chunksection = chunk.getSection(j1);
+
+                chunksection.acquire();
+                set.add(chunksection);
             }
 
             return CompletableFuture.supplyAsync(Util.wrapThreadWithTaskName("wgen_fill_noise", () -> {
                 return this.doFill(blender, structureAccessor, noiseConfig, chunk, j, k);
-            }), Util.backgroundExecutor()).whenCompleteAsync((chunkAccess, throwable) -> {
-                for(LevelChunkSection levelChunkSection : set) {
-                    levelChunkSection.release();
+            }), Util.backgroundExecutor()).whenCompleteAsync((ichunkaccess1, throwable) -> {
+                Iterator iterator = set.iterator();
+
+                while (iterator.hasNext()) {
+                    LevelChunkSection chunksection1 = (LevelChunkSection) iterator.next();
+
+                    chunksection1.release();
                 }
 
             }, executor);
@@ -278,71 +303,77 @@
     }
 
     private ChunkAccess doFill(Blender blender, StructureManager structureAccessor, RandomState noiseConfig, ChunkAccess chunk, int minimumCellY, int cellHeight) {
-        NoiseChunk noiseChunk = chunk.getOrCreateNoiseChunk((chunkx) -> {
-            return this.createNoiseChunk(chunkx, structureAccessor, blender, noiseConfig);
+        NoiseChunk noisechunk = chunk.getOrCreateNoiseChunk((ichunkaccess1) -> {
+            return this.createNoiseChunk(ichunkaccess1, structureAccessor, blender, noiseConfig);
         });
         Heightmap heightmap = chunk.getOrCreateHeightmapUnprimed(Heightmap.Types.OCEAN_FLOOR_WG);
-        Heightmap heightmap2 = chunk.getOrCreateHeightmapUnprimed(Heightmap.Types.WORLD_SURFACE_WG);
-        ChunkPos chunkPos = chunk.getPos();
-        int i = chunkPos.getMinBlockX();
-        int j = chunkPos.getMinBlockZ();
-        Aquifer aquifer = noiseChunk.aquifer();
-        noiseChunk.initializeForFirstCellX();
-        BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos();
-        int k = noiseChunk.cellWidth();
-        int l = noiseChunk.cellHeight();
-        int m = 16 / k;
-        int n = 16 / k;
+        Heightmap heightmap1 = chunk.getOrCreateHeightmapUnprimed(Heightmap.Types.WORLD_SURFACE_WG);
+        ChunkPos chunkcoordintpair = chunk.getPos();
+        int k = chunkcoordintpair.getMinBlockX();
+        int l = chunkcoordintpair.getMinBlockZ();
+        Aquifer aquifer = noisechunk.aquifer();
 
-        for(int o = 0; o < m; ++o) {
-            noiseChunk.advanceCellX(o);
+        noisechunk.initializeForFirstCellX();
+        BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos();
+        int i1 = noisechunk.cellWidth();
+        int j1 = noisechunk.cellHeight();
+        int k1 = 16 / i1;
+        int l1 = 16 / i1;
 
-            for(int p = 0; p < n; ++p) {
-                LevelChunkSection levelChunkSection = chunk.getSection(chunk.getSectionsCount() - 1);
+        for (int i2 = 0; i2 < k1; ++i2) {
+            noisechunk.advanceCellX(i2);
 
-                for(int q = cellHeight - 1; q >= 0; --q) {
-                    noiseChunk.selectCellYZ(q, p);
+            for (int j2 = 0; j2 < l1; ++j2) {
+                LevelChunkSection chunksection = chunk.getSection(chunk.getSectionsCount() - 1);
 
-                    for(int r = l - 1; r >= 0; --r) {
-                        int s = (minimumCellY + q) * l + r;
-                        int t = s & 15;
-                        int u = chunk.getSectionIndex(s);
-                        if (chunk.getSectionIndex(levelChunkSection.bottomBlockY()) != u) {
-                            levelChunkSection = chunk.getSection(u);
+                for (int k2 = cellHeight - 1; k2 >= 0; --k2) {
+                    noisechunk.selectCellYZ(k2, j2);
+
+                    for (int l2 = j1 - 1; l2 >= 0; --l2) {
+                        int i3 = (minimumCellY + k2) * j1 + l2;
+                        int j3 = i3 & 15;
+                        int k3 = chunk.getSectionIndex(i3);
+
+                        if (chunk.getSectionIndex(chunksection.bottomBlockY()) != k3) {
+                            chunksection = chunk.getSection(k3);
                         }
 
-                        double d = (double)r / (double)l;
-                        noiseChunk.updateForY(s, d);
+                        double d0 = (double) l2 / (double) j1;
 
-                        for(int v = 0; v < k; ++v) {
-                            int w = i + o * k + v;
-                            int x = w & 15;
-                            double e = (double)v / (double)k;
-                            noiseChunk.updateForX(w, e);
+                        noisechunk.updateForY(i3, d0);
 
-                            for(int y = 0; y < k; ++y) {
-                                int z = j + p * k + y;
-                                int aa = z & 15;
-                                double f = (double)y / (double)k;
-                                noiseChunk.updateForZ(z, f);
-                                BlockState blockState = noiseChunk.getInterpolatedState();
-                                if (blockState == null) {
-                                    blockState = this.defaultBlock;
+                        for (int l3 = 0; l3 < i1; ++l3) {
+                            int i4 = k + i2 * i1 + l3;
+                            int j4 = i4 & 15;
+                            double d1 = (double) l3 / (double) i1;
+
+                            noisechunk.updateForX(i4, d1);
+
+                            for (int k4 = 0; k4 < i1; ++k4) {
+                                int l4 = l + j2 * i1 + k4;
+                                int i5 = l4 & 15;
+                                double d2 = (double) k4 / (double) i1;
+
+                                noisechunk.updateForZ(l4, d2);
+                                BlockState iblockdata = noisechunk.getInterpolatedState();
+
+                                if (iblockdata == null) {
+                                    iblockdata = this.defaultBlock;
                                 }
 
-                                blockState = this.debugPreliminarySurfaceLevel(noiseChunk, w, s, z, blockState);
-                                if (blockState != AIR && !SharedConstants.debugVoidTerrain(chunk.getPos())) {
-                                    if (blockState.getLightEmission() != 0 && chunk instanceof ProtoChunk) {
-                                        mutableBlockPos.set(w, s, z);
-                                        ((ProtoChunk)chunk).addLight(mutableBlockPos);
+                                iblockdata = this.debugPreliminarySurfaceLevel(noisechunk, i4, i3, l4, iblockdata);
+                                if (iblockdata != NoiseBasedChunkGenerator.AIR && !SharedConstants.debugVoidTerrain(chunk.getPos())) {
+                                    if (iblockdata.getLightEmission() != 0 && chunk instanceof ProtoChunk) {
+                                        blockposition_mutableblockposition.set(i4, i3, l4);
+                                        ((ProtoChunk) chunk).addLight(blockposition_mutableblockposition);
                                     }
 
-                                    levelChunkSection.setBlockState(x, t, aa, blockState, false);
-                                    heightmap.update(x, s, aa, blockState);
-                                    heightmap2.update(x, s, aa, blockState);
-                                    if (aquifer.shouldScheduleFluidUpdate() && !blockState.getFluidState().isEmpty()) {
-                                        mutableBlockPos.set(w, s, z);
-                                        chunk.markPosForPostprocessing(mutableBlockPos);
+                                    chunksection.setBlockState(j4, j3, i5, iblockdata, false);
+                                    heightmap.update(j4, i3, i5, iblockdata);
+                                    heightmap1.update(j4, i3, i5, iblockdata);
+                                    if (aquifer.shouldScheduleFluidUpdate() && !iblockdata.getFluidState().isEmpty()) {
+                                        blockposition_mutableblockposition.set(i4, i3, l4);
+                                        chunk.markPosForPostprocessing(blockposition_mutableblockposition);
                                     }
                                 }
                             }
@@ -351,10 +382,10 @@
                 }
             }
 
-            noiseChunk.swapSlices();
+            noisechunk.swapSlices();
         }
 
-        noiseChunk.stopInterpolation();
+        noisechunk.stopInterpolation();
         return chunk;
     }
 
@@ -364,27 +395,28 @@
 
     @Override
     public int getGenDepth() {
-        return this.settings.value().noiseSettings().height();
+        return ((NoiseGeneratorSettings) this.settings.value()).noiseSettings().height();
     }
 
     @Override
     public int getSeaLevel() {
-        return this.settings.value().seaLevel();
+        return ((NoiseGeneratorSettings) this.settings.value()).seaLevel();
     }
 
     @Override
     public int getMinY() {
-        return this.settings.value().noiseSettings().minY();
+        return ((NoiseGeneratorSettings) this.settings.value()).noiseSettings().minY();
     }
 
     @Override
     public void spawnOriginalMobs(WorldGenRegion region) {
-        if (!this.settings.value().disableMobGeneration()) {
-            ChunkPos chunkPos = region.getCenter();
-            Holder<Biome> holder = region.getBiome(chunkPos.getWorldPosition().atY(region.getMaxBuildHeight() - 1));
-            WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(RandomSupport.generateUniqueSeed()));
-            worldgenRandom.setDecorationSeed(region.getSeed(), chunkPos.getMinBlockX(), chunkPos.getMinBlockZ());
-            NaturalSpawner.spawnMobsForChunkGeneration(region, holder, chunkPos, worldgenRandom);
+        if (!((NoiseGeneratorSettings) this.settings.value()).disableMobGeneration()) {
+            ChunkPos chunkcoordintpair = region.getCenter();
+            Holder<Biome> holder = region.getBiome(chunkcoordintpair.getWorldPosition().atY(region.getMaxBuildHeight() - 1));
+            WorldgenRandom seededrandom = new WorldgenRandom(new LegacyRandomSource(RandomSupport.generateUniqueSeed()));
+
+            seededrandom.setDecorationSeed(region.getSeed(), chunkcoordintpair.getMinBlockX(), chunkcoordintpair.getMinBlockZ());
+            NaturalSpawner.spawnMobsForChunkGeneration(region, holder, chunkcoordintpair, seededrandom);
         }
     }
 }
