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

import net.minecraft.world.level.levelgen.feature.configurations.DecoratorConfiguration;
import java.util.stream.Stream;
import net.minecraft.core.BlockPos;
import java.util.Random;
import com.mojang.datafixers.Dynamic;
import java.util.function.Function;
import net.minecraft.world.level.levelgen.feature.configurations.ChanceRangeDecoratorConfiguration;
import net.minecraft.world.level.levelgen.placement.SimpleFeatureDecorator;

public class ChanceRangeDecorator extends SimpleFeatureDecorator<ChanceRangeDecoratorConfiguration> {
    public ChanceRangeDecorator(final Function<Dynamic<?>, ? extends ChanceRangeDecoratorConfiguration> function) {
        super(function);
    }
    
    public Stream<BlockPos> place(final Random random, final ChanceRangeDecoratorConfiguration cgg, final BlockPos fk) {
        if (random.nextFloat() < cgg.chance) {
            final int integer5 = random.nextInt(16) + fk.getX();
            final int integer6 = random.nextInt(16) + fk.getZ();
            final int integer7 = random.nextInt(cgg.top - cgg.topOffset) + cgg.bottomOffset;
            return Stream.<BlockPos>of(new BlockPos(integer5, integer7, integer6));
        }
        return Stream.<BlockPos>empty();
    }
}
