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.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 ChanceHeightmapDoubleDecorator extends FeatureDecorator<ChanceDecoratorConfiguration> {
    public ChanceHeightmapDoubleDecorator(final Function<Dynamic<?>, ? extends ChanceDecoratorConfiguration> function) {
        super(function);
    }
    
    @Override
    public Stream<BlockPos> getPositions(final LevelAccessor bjx, final ChunkGenerator<? extends ChunkGeneratorSettings> caa, final Random random, final ChanceDecoratorConfiguration cjd, final BlockPos fk) {
        if (random.nextFloat() >= 1.0f / cjd.chance) {
            return Stream.<BlockPos>empty();
        }
        final int integer7 = random.nextInt(16) + fk.getX();
        final int integer8 = random.nextInt(16) + fk.getZ();
        final int integer9 = bjx.getHeight(Heightmap.Types.MOTION_BLOCKING, integer7, integer8) * 2;
        if (integer9 <= 0) {
            return Stream.<BlockPos>empty();
        }
        return Stream.<BlockPos>of(new BlockPos(integer7, random.nextInt(integer9), integer8));
    }
}
