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

import java.util.function.BiFunction;
import com.mojang.datafixers.kinds.Applicative;
import com.mojang.datafixers.kinds.App;
import com.mojang.serialization.codecs.RecordCodecBuilder;
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.FeatureConfiguration;

public class WeightedConfiguredFeature<FC extends FeatureConfiguration> {
    public static final Codec<WeightedConfiguredFeature<?>> CODEC;
    public final ConfiguredFeature<FC, ?> feature;
    public final float chance;
    
    public WeightedConfiguredFeature(final ConfiguredFeature<FC, ?> ckb, final float float2) {
        this.feature = ckb;
        this.chance = float2;
    }
    
    public boolean place(final WorldGenLevel bqu, final StructureFeatureManager bqq, final ChunkGenerator cha, final Random random, final BlockPos fu) {
        return this.feature.place(bqu, bqq, cha, random, fu);
    }
    
    static {
        CODEC = RecordCodecBuilder.create(instance -> ((RecordCodecBuilder.Instance)instance).group((App)ConfiguredFeature.CODEC.fieldOf("feature").forGetter(cmw -> cmw.feature), (App)Codec.FLOAT.fieldOf("chance").forGetter(cmw -> cmw.chance)).apply(instance, (BiFunction)WeightedConfiguredFeature::new));
    }
}
