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

import net.minecraft.world.level.levelgen.feature.configurations.DecoratorConfiguration;
import net.minecraft.world.level.levelgen.Heightmap;
import java.util.stream.IntStream;
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 CountChanceHeightmapDecorator extends FeatureDecorator<FrequencyChanceDecoratorConfiguration> {
    public CountChanceHeightmapDecorator(final Function<Dynamic<?>, ? extends FrequencyChanceDecoratorConfiguration> function) {
        super(function);
    }
    
    @Override
    public Stream<BlockPos> getPositions(final LevelAccessor bjx, final ChunkGenerator<? extends ChunkGeneratorSettings> caa, final Random random, final FrequencyChanceDecoratorConfiguration ckc, final BlockPos fk) {
        final int integer5;
        final int integer6;
        final int integer7;
        return IntStream.range(0, ckc.count).filter(integer -> random.nextFloat() < ckc.chance).<BlockPos>mapToObj(integer -> {
            integer5 = random.nextInt(16) + fk.getX();
            integer6 = random.nextInt(16) + fk.getZ();
            integer7 = bjx.getHeight(Heightmap.Types.MOTION_BLOCKING, integer5, integer6);
            return new BlockPos(integer5, integer7, integer6);
        });
    }
}
