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.chunk.ChunkGenerator;
import net.minecraft.world.level.LevelAccessor;
import com.mojang.serialization.Codec;

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