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

import java.util.Map;
import com.google.common.collect.ImmutableMap;
import com.mojang.datafixers.Dynamic;
import com.mojang.datafixers.types.DynamicOps;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;

public class RandomBooleanFeatureConfiguration implements FeatureConfiguration {
    public final ConfiguredFeature<?, ?> featureTrue;
    public final ConfiguredFeature<?, ?> featureFalse;
    
    public RandomBooleanFeatureConfiguration(final ConfiguredFeature<?, ?> cdc1, final ConfiguredFeature<?, ?> cdc2) {
        this.featureTrue = cdc1;
        this.featureFalse = cdc2;
    }
    
    @Override
    public <T> Dynamic<T> serialize(final DynamicOps<T> dynamicOps) {
        return (Dynamic<T>)new Dynamic((DynamicOps)dynamicOps, dynamicOps.createMap((Map)ImmutableMap.of(dynamicOps.createString("feature_true"), this.featureTrue.<T>serialize(dynamicOps).getValue(), dynamicOps.createString("feature_false"), this.featureFalse.<T>serialize(dynamicOps).getValue())));
    }
    
    public static <T> RandomBooleanFeatureConfiguration deserialize(final Dynamic<T> dynamic) {
        final ConfiguredFeature<?, ?> cdc2 = ConfiguredFeature.deserialize((com.mojang.datafixers.Dynamic<Object>)dynamic.get("feature_true").orElseEmptyMap());
        final ConfiguredFeature<?, ?> cdc3 = ConfiguredFeature.deserialize((com.mojang.datafixers.Dynamic<Object>)dynamic.get("feature_false").orElseEmptyMap());
        return new RandomBooleanFeatureConfiguration(cdc2, cdc3);
    }
}
