package net.minecraft.world.level.levelgen.placement;

import net.minecraft.world.level.levelgen.feature.configurations.DecoratorConfiguration;
import java.util.stream.IntStream;
import net.minecraft.world.level.biome.Biome;
import java.util.stream.Stream;
import net.minecraft.core.BlockPos;
import java.util.Random;
import net.minecraft.world.level.levelgen.ChunkGeneratorSettings;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.LevelAccessor;
import com.mojang.datafixers.Dynamic;
import java.util.function.Function;

public class TopSolidHeightMapNoiseBasedDecorator extends FeatureDecorator<NoiseCountFactorDecoratorConfiguration> {
    public TopSolidHeightMapNoiseBasedDecorator(final Function<Dynamic<?>, ? extends NoiseCountFactorDecoratorConfiguration> function) {
        super(function);
    }
    
    @Override
    public Stream<BlockPos> getPositions(final LevelAccessor bjx, final ChunkGenerator<? extends ChunkGeneratorSettings> caa, final Random random, final NoiseCountFactorDecoratorConfiguration ckj, final BlockPos fk) {
        final double double7 = Biome.BIOME_INFO_NOISE.getValue(fk.getX() / ckj.noiseFactor, fk.getZ() / ckj.noiseFactor, false);
        final int integer9 = (int)Math.ceil((double7 + ckj.noiseOffset) * ckj.noiseToCountRatio);
        final int integer10;
        final int integer11;
        final int integer12;
        return IntStream.range(0, integer9).<BlockPos>mapToObj(integer -> {
            integer10 = random.nextInt(16) + fk.getX();
            integer11 = random.nextInt(16) + fk.getZ();
            integer12 = bjx.getHeight(ckj.heightmap, integer10, integer11);
            return new BlockPos(integer10, integer12, integer11);
        });
    }
}
