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

import net.minecraft.core.Registry;
import com.mojang.datafixers.Dynamic;
import java.util.function.Function;

public class BlockStateProviderType<P extends BlockStateProvider> {
    public static final BlockStateProviderType<SimpleStateProvider> SIMPLE_STATE_PROVIDER;
    public static final BlockStateProviderType<WeightedStateProvider> WEIGHTED_STATE_PROVIDER;
    public static final BlockStateProviderType<PlainFlowerProvider> PLAIN_FLOWER_PROVIDER;
    public static final BlockStateProviderType<ForestFlowerProvider> FOREST_FLOWER_PROVIDER;
    private final Function<Dynamic<?>, P> deserializer;
    
    private static <P extends BlockStateProvider> BlockStateProviderType<P> register(final String string, final Function<Dynamic<?>, P> function) {
        return Registry.<BlockStateProviderType<P>>register(Registry.BLOCKSTATE_PROVIDER_TYPES, string, new BlockStateProviderType<P>(function));
    }
    
    private BlockStateProviderType(final Function<Dynamic<?>, P> function) {
        this.deserializer = function;
    }
    
    public P deserialize(final Dynamic<?> dynamic) {
        return this.deserializer.apply(dynamic);
    }
    
    static {
        SIMPLE_STATE_PROVIDER = BlockStateProviderType.<SimpleStateProvider>register("simple_state_provider", SimpleStateProvider::new);
        WEIGHTED_STATE_PROVIDER = BlockStateProviderType.<WeightedStateProvider>register("weighted_state_provider", WeightedStateProvider::new);
        PLAIN_FLOWER_PROVIDER = BlockStateProviderType.<PlainFlowerProvider>register("plain_flower_provider", PlainFlowerProvider::new);
        FOREST_FLOWER_PROVIDER = BlockStateProviderType.<ForestFlowerProvider>register("forest_flower_provider", ForestFlowerProvider::new);
    }
}
