package top.azimkin.militaryarmor;

import net.minecraft.core.registries.Registries;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.RegistryObject;

import java.util.concurrent.ThreadLocalRandom;


public class ModCreativeTabs {
    private static final DeferredRegister<CreativeModeTab> CREATIVE_MODE_TABS = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, MilitaryArmor.MOD_ID);

    public static final RegistryObject<CreativeModeTab> MILITARY_ARMOR_TAB = CREATIVE_MODE_TABS.register("example_tab", () -> CreativeModeTab.builder()
            .icon(() -> ModItems.ITEM_LIST.get(ThreadLocalRandom.current().nextInt(ModItems.ITEM_LIST.size())).get().getDefaultInstance())
            .title(Component.translatable("item_group." + MilitaryArmor.MOD_ID + ".main"))
            .displayItems((parameters, output) -> {
                for (var i : ModItems.ITEM_LIST) {
                    output.accept(i.get());
                }
            })
            .build());

    public static void register(IEventBus bus) {
        CREATIVE_MODE_TABS.register(bus);
    }
}
