package top.r3944realms.lib39;

import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import top.r3944realms.lib39.core.network.NetworkHandler;
import top.r3944realms.lib39.core.register.ForgeLib39BlockEntities;
import top.r3944realms.lib39.core.register.ForgeLib39Blocks;
import top.r3944realms.lib39.core.register.ForgeLib39Items;
import top.r3944realms.lib39.core.register.ForgeLib39SoundEvents;
import top.r3944realms.lib39.example.ForgeLib39Example;

/**
 * The type Lib 39.
 */
@Mod(Lib39.MOD_ID)
public class Lib39Forge {
    /**
     * Instantiates a new Lib 39.
     */
    public Lib39Forge() {
        Lib39.initialize();
        initialize();
    }

    /**
     * Initialize.
     */
    public static void initialize() {
        Lib39.LOGGER.info("[Lib39-Forge] Hello Forge");
        IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
        ForgeLib39Blocks.register(modEventBus);
        ForgeLib39Items.register(modEventBus);
        ForgeLib39BlockEntities.register(modEventBus);
        ForgeLib39SoundEvents.register(modEventBus);
        NetworkHandler.register();
        if (Lib39.shouldRegisterExamples()) {
            Lib39.LOGGER.info("[Lib39-Forge] Registering Examples");
            registerExamples();
        }
        Lib39.LOGGER.info("[Lib39-Forge] Finished Initializing.");

    }

    /**
     * Register examples.
     */
    static void registerExamples() {
        Lib39.LOGGER.info("[Lib39-Forge] Starting example demonstrations");
        try {
            // 创建示例实例并演示功能
            ForgeLib39Example example = new ForgeLib39Example();
            example.demonstrateFeature();

            Lib39.LOGGER.info("[Lib39-Forge] Example demonstrations completed successfully");
        } catch (Exception e) {
            Lib39.LOGGER.error("[Lib39-Forge] Failed to demonstrate examples", e);
        }
    }
}
