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

import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
import net.minecraft.world.level.block.state.BlockState;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.LevelAccessor;
import com.mojang.datafixers.Dynamic;
import java.util.function.Function;
import net.minecraft.world.level.levelgen.feature.configurations.RandomPatchConfiguration;

public class DefaultFlowerFeature extends AbstractFlowerFeature<RandomPatchConfiguration> {
    public DefaultFlowerFeature(final Function<Dynamic<?>, ? extends RandomPatchConfiguration> function) {
        super(function);
    }
    
    @Override
    public boolean isValid(final LevelAccessor bjx, final BlockPos fk, final RandomPatchConfiguration chb) {
        return !chb.blacklist.contains(bjx.getBlockState(fk));
    }
    
    @Override
    public int getCount(final RandomPatchConfiguration chb) {
        return chb.tries;
    }
    
    @Override
    public BlockPos getPos(final Random random, final BlockPos fk, final RandomPatchConfiguration chb) {
        return fk.offset(random.nextInt(chb.xspread) - random.nextInt(chb.xspread), random.nextInt(chb.yspread) - random.nextInt(chb.yspread), random.nextInt(chb.zspread) - random.nextInt(chb.zspread));
    }
    
    @Override
    public BlockState getRandomFlower(final Random random, final BlockPos fk, final RandomPatchConfiguration chb) {
        return chb.stateProvider.getState(random, fk);
    }
}
