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.serialization.Codec;
import net.minecraft.world.level.levelgen.feature.configurations.RandomPatchConfiguration;

public class DefaultFlowerFeature extends AbstractFlowerFeature<RandomPatchConfiguration> {
    public DefaultFlowerFeature(final Codec<RandomPatchConfiguration> codec) {
        super(codec);
    }
    
    @Override
    public boolean isValid(final LevelAccessor bqc, final BlockPos fu, final RandomPatchConfiguration cog) {
        return !cog.blacklist.contains(bqc.getBlockState(fu));
    }
    
    @Override
    public int getCount(final RandomPatchConfiguration cog) {
        return cog.tries;
    }
    
    @Override
    public BlockPos getPos(final Random random, final BlockPos fu, final RandomPatchConfiguration cog) {
        return fu.offset(random.nextInt(cog.xspread) - random.nextInt(cog.xspread), random.nextInt(cog.yspread) - random.nextInt(cog.yspread), random.nextInt(cog.zspread) - random.nextInt(cog.zspread));
    }
    
    @Override
    public BlockState getRandomFlower(final Random random, final BlockPos fu, final RandomPatchConfiguration cog) {
        return cog.stateProvider.getState(random, fu);
    }
}
