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

import java.util.function.Function;
import net.minecraft.core.Registry;
import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import net.minecraft.core.BlockPos;
import java.util.Random;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.StructureFeatureManager;
import net.minecraft.world.level.WorldGenLevel;
import com.mojang.serialization.Codec;
import net.minecraft.world.level.levelgen.feature.configurations.DecoratorConfiguration;

public class ConfiguredDecorator<DC extends DecoratorConfiguration> {
    public static final Codec<ConfiguredDecorator<?>> CODEC;
    public final FeatureDecorator<DC> decorator;
    public final DC config;
    
    public ConfiguredDecorator(final FeatureDecorator<DC> csc, final DC cnn) {
        this.decorator = csc;
        this.config = cnn;
    }
    
    public <FC extends FeatureConfiguration, F extends Feature<FC>> boolean place(final WorldGenLevel bqu, final StructureFeatureManager bqq, final ChunkGenerator cha, final Random random, final BlockPos fu, final ConfiguredFeature<FC, F> ckb) {
        return this.decorator.<FC, F>placeFeature(bqu, bqq, cha, random, fu, this.config, ckb);
    }
    
    static {
        CODEC = Registry.DECORATOR.dispatch("name", crl -> crl.decorator, (Function)FeatureDecorator::configuredCodec);
    }
}
