package top.r3944realms.lib39.core.register;

import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.level.block.Block;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import top.r3944realms.lib39.Lib39;
import top.r3944realms.lib39.content.block.DollBlock;
import top.r3944realms.lib39.content.block.WallDollBlock;
import top.r3944realms.lib39.util.block.BlockRegistryBuilder;

import java.util.function.Supplier;

/**
 * The type Lib 39 blocks.
 */
public class FabricLib39Blocks {
    /**
     * Init.
     */
    public static void init() {
       Lib39Blocks.DOLL = BlockRegistryBuilder
               .create()
               .withName("doll")
               .registerBlock((name , block) -> register(name, block.get()), DollBlock::new)
               .build();
       Lib39Blocks.WALL_DOLL = BlockRegistryBuilder
               .create()
               .withName("wall_doll")
               .registerBlock((name , block) -> register(name, block.get()), WallDollBlock::new)
               .build();
   }

    /**
     * Register @ not null supplier.
     *
     * @param <T>   the type parameter
     * @param path  the path
     * @param block the block
     * @return the @ not null supplier
     */
    @Contract(pure = true)
    public static <T extends Block> @NotNull Supplier<T> register(String path, T block) {
        T item = Registry.register(BuiltInRegistries.BLOCK, Lib39.rl(path), block);
        return () -> item;
    }

}
