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

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

public class SimpleRandomFeatureConfiguration implements FeatureConfiguration {
    public final List<ConfiguredFeature<?, ?>> features;
    
    public SimpleRandomFeatureConfiguration(final List<ConfiguredFeature<?, ?>> list) {
        this.features = list;
    }
    
    @Override
    public <T> Dynamic<T> serialize(final DynamicOps<T> dynamicOps) {
        return (Dynamic<T>)new Dynamic((DynamicOps)dynamicOps, dynamicOps.createMap((Map)ImmutableMap.of(dynamicOps.createString("features"), dynamicOps.createList((Stream)this.features.stream().map(cdc -> cdc.<T>serialize(dynamicOps).getValue())))));
    }
    
    public static <T> SimpleRandomFeatureConfiguration deserialize(final Dynamic<T> dynamic) {
        final List<ConfiguredFeature<?, ?>> list2 = (List<ConfiguredFeature<?, ?>>)dynamic.get("features").asList((Function)ConfiguredFeature::deserialize);
        return new SimpleRandomFeatureConfiguration(list2);
    }
}
