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

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

public class BlockPlacerType<P extends BlockPlacer> {
    public static final BlockPlacerType<SimpleBlockPlacer> SIMPLE_BLOCK_PLACER;
    public static final BlockPlacerType<DoublePlantPlacer> DOUBLE_PLANT_PLACER;
    public static final BlockPlacerType<ColumnPlacer> COLUMN_PLACER;
    private final Function<Dynamic<?>, P> deserializer;
    
    private static <P extends BlockPlacer> BlockPlacerType<P> register(final String string, final Function<Dynamic<?>, P> function) {
        return Registry.<BlockPlacerType<P>>register(Registry.BLOCK_PLACER_TYPES, string, new BlockPlacerType<P>(function));
    }
    
    private BlockPlacerType(final Function<Dynamic<?>, P> function) {
        this.deserializer = function;
    }
    
    public P deserialize(final Dynamic<?> dynamic) {
        return this.deserializer.apply(dynamic);
    }
    
    static {
        SIMPLE_BLOCK_PLACER = BlockPlacerType.<SimpleBlockPlacer>register("simple_block_placer", SimpleBlockPlacer::new);
        DOUBLE_PLANT_PLACER = BlockPlacerType.<DoublePlantPlacer>register("double_plant_placer", DoublePlantPlacer::new);
        COLUMN_PLACER = BlockPlacerType.<ColumnPlacer>register("column_placer", ColumnPlacer::new);
    }
}
