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

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

public class TreeDecoratorType<P extends TreeDecorator> {
    public static final TreeDecoratorType<TrunkVineDecorator> TRUNK_VINE;
    public static final TreeDecoratorType<LeaveVineDecorator> LEAVE_VINE;
    public static final TreeDecoratorType<CocoaDecorator> COCOA;
    public static final TreeDecoratorType<BeehiveDecorator> BEEHIVE;
    public static final TreeDecoratorType<AlterGroundDecorator> ALTER_GROUND;
    private final Function<Dynamic<?>, P> deserializer;
    
    private static <P extends TreeDecorator> TreeDecoratorType<P> register(final String string, final Function<Dynamic<?>, P> function) {
        return Registry.<TreeDecoratorType<P>>register(Registry.TREE_DECORATOR_TYPES, string, new TreeDecoratorType<P>(function));
    }
    
    private TreeDecoratorType(final Function<Dynamic<?>, P> function) {
        this.deserializer = function;
    }
    
    public P deserialize(final Dynamic<?> dynamic) {
        return this.deserializer.apply(dynamic);
    }
    
    static {
        TRUNK_VINE = TreeDecoratorType.<TrunkVineDecorator>register("trunk_vine", TrunkVineDecorator::new);
        LEAVE_VINE = TreeDecoratorType.<LeaveVineDecorator>register("leave_vine", LeaveVineDecorator::new);
        COCOA = TreeDecoratorType.<CocoaDecorator>register("cocoa", CocoaDecorator::new);
        BEEHIVE = TreeDecoratorType.<BeehiveDecorator>register("beehive", BeehiveDecorator::new);
        ALTER_GROUND = TreeDecoratorType.<AlterGroundDecorator>register("alter_ground", AlterGroundDecorator::new);
    }
}
