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

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.world.level.levelgen.feature.Feature;
import net.minecraft.core.Registry;
import net.minecraft.world.level.levelgen.placement.ConfiguredDecorator;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import com.mojang.serialization.Codec;

public class DecoratedFeatureConfiguration implements FeatureConfiguration {
    public static final Codec<DecoratedFeatureConfiguration> CODEC;
    public final ConfiguredFeature<?, ?> feature;
    public final ConfiguredDecorator<?> decorator;
    
    public DecoratedFeatureConfiguration(final ConfiguredFeature<?, ?> ckb, final ConfiguredDecorator<?> crl) {
        this.feature = ckb;
        this.decorator = crl;
    }
    
    @Override
    public String toString() {
        return String.format("< %s [%s | %s] >", this.getClass().getSimpleName(), Registry.FEATURE.getKey(this.feature.feature), Registry.DECORATOR.getKey(this.decorator.decorator));
    }
    
    static {
        CODEC = RecordCodecBuilder.create(instance -> ((RecordCodecBuilder.Instance)instance).group((App)ConfiguredFeature.CODEC.fieldOf("feature").forGetter(cnm -> cnm.feature), (App)ConfiguredDecorator.CODEC.fieldOf("decorator").forGetter(cnm -> cnm.decorator)).apply(instance, (BiFunction)DecoratedFeatureConfiguration::new));
    }
}
