package me.zacharias.compadability;

import com.mojang.logging.LogUtils;
import me.zacharias.compadability.register.Items;
import me.zacharias.compadability.register.Modules;
import mekanism.api.MekanismIMC;
import mekanism.common.registries.MekanismCreativeTabs;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.ModContainer;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.config.ModConfig;
import net.neoforged.fml.event.lifecycle.InterModEnqueueEvent;
import net.neoforged.neoforge.event.BuildCreativeModeTabContentsEvent;
import org.slf4j.Logger;

@Mod(Compadability.MODID)
public class Compadability {
    public static final String MODID = "compadability";
    private static final Logger LOGGER = LogUtils.getLogger();

    public Compadability(IEventBus bus, ModContainer modContainer) {

        modContainer.registerConfig(ModConfig.Type.COMMON, Config.SPEC);

        Items.register(bus);
        Modules.register(bus);
        bus.addListener(this::imcQueue);
        bus.addListener(this::buildCreativeModeTabContents);
    }

    private void imcQueue(InterModEnqueueEvent event) {
        MekanismIMC.addMekaSuitBodyarmorModules(Modules.CLIMATE_CONTROL_UNIT);
        MekanismIMC.addMekaSuitHelmetModules(Modules.WATER_PURIFIED_DRINKING_UNIT);
    }

    private void buildCreativeModeTabContents(BuildCreativeModeTabContentsEvent event) {
        if (event.getTab() == MekanismCreativeTabs.MEKANISM.get()) {
            event.accept(Items.CLIMATE_CONTROL_UNIT);
            event.accept(Items.WATER_PURIFIED_DRINKING_UNIT);
        }
    }
}
