package jesse.keeblarcraft.CustomItems;

import java.util.Map.Entry;

import jesse.keeblarcraft.Keeblarcraft;
import jesse.keeblarcraft.CustomBlocks.BlockManager;
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
import net.minecraft.block.Block;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;

public class CustomItemGroups {

    // This is the custom mod group for the mod
    public static final ItemGroup MOD_GROUP = Registry.register(Registries.ITEM_GROUP,
                                                                new Identifier(Keeblarcraft.MOD_ID, "keeblarcraft"),
                                                                FabricItemGroup.builder().displayName(Text.translatable("itemgroup.keeblarcraft"))
                                                                .icon(() -> new ItemStack(Items.ANVIL)).entries((displayContext, entries) -> {
                                                                    // We iterate through all the modded items and add them to the custom item group here
                                                                    for (int i = 0; i < ItemManager.itemList.size(); i++) {
                                                                        entries.add(ItemManager.itemList.get(i));
                                                                    }

                                                                    // We iterate through all the modded blocks and add them to the custom block group here
                                                                    for(Entry<String, Block> blocks : BlockManager.blockList.entrySet()) {
                                                                        entries.add(blocks.getValue());
                                                                    }
                                                                }).build());

    /////////////////////////////////////////////////////////////////////////////
    /// @fn         RegisterGroups
    ///
    /// @brief      Glorified print statement that the class has initialized
    ///             basically - meaning that all item groups have registered
    /////////////////////////////////////////////////////////////////////////////
    public static void RegisterGroups() {
        Keeblarcraft.LOGGER.info("Registering item groups for " + Keeblarcraft.MOD_ID);
    }
}
