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

import net.minecraft.resources.ResourceLocation;
import java.util.function.Supplier;
import net.minecraft.core.Registry;
import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProviderType;
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.stateproviders.BlockStateProvider;

public class HugeMushroomFeatureConfiguration implements FeatureConfiguration {
    public final BlockStateProvider capProvider;
    public final BlockStateProvider stemProvider;
    public final int foliageRadius;
    
    public HugeMushroomFeatureConfiguration(final BlockStateProvider chw1, final BlockStateProvider chw2, final int integer) {
        this.capProvider = chw1;
        this.stemProvider = chw2;
        this.foliageRadius = integer;
    }
    
    @Override
    public <T> Dynamic<T> serialize(final DynamicOps<T> dynamicOps) {
        final ImmutableMap.Builder<T, T> builder3 = ImmutableMap.<T, T>builder();
        builder3.put((T)dynamicOps.createString("cap_provider"), this.capProvider.<T>serialize(dynamicOps)).put((T)dynamicOps.createString("stem_provider"), this.stemProvider.<T>serialize(dynamicOps)).put((T)dynamicOps.createString("foliage_radius"), (T)dynamicOps.createInt(this.foliageRadius));
        return (Dynamic<T>)new Dynamic((DynamicOps)dynamicOps, dynamicOps.createMap((Map)builder3.build()));
    }
    
    public static <T> HugeMushroomFeatureConfiguration deserialize(final Dynamic<T> dynamic) {
        final BlockStateProviderType<?> chx2 = Registry.BLOCKSTATE_PROVIDER_TYPES.get(new ResourceLocation(dynamic.get("cap_provider").get("type").asString().<Throwable>orElseThrow(RuntimeException::new)));
        final BlockStateProviderType<?> chx3 = Registry.BLOCKSTATE_PROVIDER_TYPES.get(new ResourceLocation(dynamic.get("stem_provider").get("type").asString().<Throwable>orElseThrow(RuntimeException::new)));
        return new HugeMushroomFeatureConfiguration((BlockStateProvider)chx2.deserialize(dynamic.get("cap_provider").orElseEmptyMap()), (BlockStateProvider)chx3.deserialize(dynamic.get("stem_provider").orElseEmptyMap()), dynamic.get("foliage_radius").asInt(2));
    }
}
