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

import java.util.function.Function;
import net.minecraft.core.Registry;
import net.minecraft.world.level.levelgen.WorldgenRandom;
import net.minecraft.world.level.levelgen.structure.StructureStart;
import net.minecraft.world.level.levelgen.feature.configurations.StructureFeatureConfiguration;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager;
import net.minecraft.world.level.biome.BiomeSource;
import net.minecraft.world.level.chunk.ChunkGenerator;
import com.mojang.serialization.Codec;
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;

public class ConfiguredStructureFeature<FC extends FeatureConfiguration, F extends StructureFeature<FC>> {
    public static final Codec<ConfiguredStructureFeature<?, ?>> CODEC;
    public final F feature;
    public final FC config;
    
    public ConfiguredStructureFeature(final F cml, final FC cnr) {
        this.feature = cml;
        this.config = cnr;
    }
    
    public StructureStart<?> generate(final ChunkGenerator cha, final BiomeSource brh, final StructureManager cva, final long long4, final ChunkPos bph, final Biome bre, final int integer, final StructureFeatureConfiguration cot) {
        return this.feature.generate(cha, brh, cva, long4, bph, bre, integer, new WorldgenRandom(), cot, this.config);
    }
    
    static {
        CODEC = Registry.STRUCTURE_FEATURE.dispatch("name", ckc -> ckc.feature, (Function)StructureFeature::configuredStructureCodec);
    }
}
