package top.r3944realms.lib39.core.register;

import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.level.block.entity.BlockEntityType;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import top.r3944realms.lib39.Lib39;
import top.r3944realms.lib39.content.block.blockentity.DollBlockEntity;

import java.util.function.Supplier;

/**
 * The type Lib 39 block entities.
 */
public class FabricLib39BlockEntities {
    /**
     * Init.
     */
    @SuppressWarnings("DataFlowIssue")
    public static void init() {
        Lib39BlockEntities.DOLL_BLOCK_ENTITY = register("doll", BlockEntityType.Builder
                        .of(DollBlockEntity::new, Lib39Blocks.DOLL.get(), Lib39Blocks.WALL_DOLL.get())
                        .build(null)
        );
    }

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