package com.trunksbomb.minetriad.registry;

import com.trunksbomb.minetriad.MineTriad;
import com.trunksbomb.minetriad.card.CardRegistry;
import com.trunksbomb.minetriad.item.CardItem;

import net.minecraft.core.registries.Registries;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.CreativeModeTab;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.neoforge.registries.DeferredHolder;
import net.neoforged.neoforge.registries.DeferredRegister;

public final class TriadCreativeTabs {
    private static final DeferredRegister<CreativeModeTab> TABS = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, MineTriad.MOD_ID);

    public static final DeferredHolder<CreativeModeTab, CreativeModeTab> CARDS = TABS.register("cards", () -> CreativeModeTab.builder()
            .title(Component.translatable("itemGroup.minetriad.cards"))
            .icon(() -> CardItem.createCardStack(CardRegistry.all().getFirst().id(), TriadItems.TRIAD_CARD.get()))
            .displayItems((parameters, output) -> {
                CardRegistry.all().forEach(card -> output.accept(CardItem.createCardStack(card.id(), TriadItems.TRIAD_CARD.get())));
            })
            .build());

    public static final DeferredHolder<CreativeModeTab, CreativeModeTab> GAMEPLAY = TABS.register("gameplay", () -> CreativeModeTab.builder()
            .title(Component.translatable("itemGroup.minetriad.gameplay"))
            .icon(() -> TriadBlocks.DUEL_TABLE.toStack())
            .displayItems((parameters, output) -> {
                output.accept(TriadItems.DECK_BOX.get());
                output.accept(TriadItems.CARD_BINDER.get());
                output.accept(TriadBlocks.DUEL_TABLE.toStack());
            })
            .build());

    private TriadCreativeTabs() {
    }

    public static void register(IEventBus eventBus) {
        TABS.register(eventBus);
    }
}
