package top.r3944realms.lendandregret;

import com.mojang.logging.LogUtils;
import net.minecraft.client.Minecraft;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.ModContainer;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.event.server.ServerStartingEvent;
import org.slf4j.Logger;
import top.r3944realms.lendandregret.contents.LARBlocks;
import top.r3944realms.lendandregret.contents.LARCreativeModeTab;
import top.r3944realms.lendandregret.contents.LARItems;

@Mod(LendAndRegret.MOD_ID)
public class LendAndRegret {
    public static final String MOD_ID = "lendandregret";
    private static final Logger LOGGER = LogUtils.getLogger();

    public LendAndRegret(IEventBus modEventBus, ModContainer modContainer) {
        modEventBus.addListener(this::commonSetup);

        LARItems.ITEMS.register(modEventBus);
        LARBlocks.BLOCKS.register(modEventBus);
        LARCreativeModeTab.CREATIVE_MODE_TABS.register(modEventBus);

        NeoForge.EVENT_BUS.register(this);
    }

    private void commonSetup(final FMLCommonSetupEvent event) {
        LOGGER.info("Lend & Regret common setup complete");
    }

    @SubscribeEvent
    public void onServerStarting(ServerStartingEvent event) {
        LOGGER.info("Lend & Regret server starting");
    }

    @EventBusSubscriber(modid = MOD_ID, value = Dist.CLIENT)
    public static class ClientModEvents {
        @SubscribeEvent
        static void onClientSetup(FMLClientSetupEvent event) {
            LOGGER.info("Lend & Regret client setup");
            LOGGER.info("Player: {}", Minecraft.getInstance().getUser().getName());
        }
    }
}
