package com.oierbravo.create_mechanical_template;

import com.mojang.logging.LogUtils;
import com.oierbravo.create_mechanical_template.infrastructure.data.ModDataGen;
import com.oierbravo.create_mechanical_template.registrate.*;
import com.simibubi.create.foundation.data.CreateRegistrate;
import com.simibubi.create.foundation.item.ItemDescription;
import com.simibubi.create.foundation.item.KineticStats;
import com.simibubi.create.foundation.item.TooltipHelper;
import com.simibubi.create.foundation.item.TooltipModifier;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.slf4j.Logger;

// The value here should match an entry in the META-INF/mods.toml file
@Mod(CreateMechanicalTemplate.MODID)
public class CreateMechanicalTemplate
{
    // Directly reference a slf4j logger
    public static final String MODID = "create_mechanical_template";
    public static final String DISPLAY_NAME = "Create Mechanical Template";

    public static final CreateRegistrate REGISTRATE = CreateRegistrate.create(MODID);
    static {
        REGISTRATE.setTooltipModifierFactory(item -> {
            return new ItemDescription.Modifier(item, TooltipHelper.Palette.STANDARD_CREATE)
                    .andThen(TooltipModifier.mapNull(KineticStats.create(item)));
        });
    }
    public static final Logger LOGGER = LogUtils.getLogger();

    public CreateMechanicalTemplate()
    {
        IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
        REGISTRATE.registerEventListeners(modEventBus);

        MinecraftForge.EVENT_BUS.register(this);
        ModConfigs.register();


        ModBlocks.register();
        ModBlockEntities.register();
        ModCreativeTabs.register(modEventBus);

        modEventBus.addListener(this::doClientStuff);
        modEventBus.addListener(ModDataGen::gatherData);


        generateLangEntries();
    }
    private void generateLangEntries(){

        registerLangCustom("itemGroup.create_mechanical_template:main", "Create Mechanical Template");
        registerLangCustom("config.jade.plugin_create_mechanical_template.template_data", "Mechanical template data");

        registerLangCustom("block.create_mechanical_template.mechanical_block.tooltip", "MECHANICAL BLOCK");
        registerLangCustom("block.create_mechanical_template.mechanical_block.tooltip.summary", "Nice _Block_ tooltip.");



    }
    private void doClientStuff(final FMLClientSetupEvent event) {
        event.enqueueWork(ModPonders::register);
    }

    public static CreateRegistrate registrate() {
        return REGISTRATE;
    }
    public static ResourceLocation asResource(String path) {
        return new ResourceLocation(MODID, path);
    }

    public static void registerLang(String id, String text){
        registerLangCustom(MODID.toLowerCase() + id, text);
    }

    public static void registerLangCustom(String id, String text){
        registrate().addRawLang(id, text);
    }

}
