package top.r3944realms.lib39;

import net.fabricmc.api.ModInitializer;
import top.r3944realms.lib39.core.event.FabricCommonEventHandler;
import top.r3944realms.lib39.core.register.FabricLib39BlockEntities;
import top.r3944realms.lib39.core.register.FabricLib39Blocks;
import top.r3944realms.lib39.core.register.FabricLib39Items;
import top.r3944realms.lib39.core.register.FabricLib39SoundEvents;
import top.r3944realms.lib39.example.FabricLib39Example;

/**
 * The type Lib 39 fabric.
 */
public class Lib39Fabric implements ModInitializer {
    
    @Override
    public void onInitialize() {
        Lib39.initialize();
        Lib39.LOGGER.info("[Lib39-Fabric] Hello Fabric!");
        FabricLib39Blocks.init();
        FabricLib39Items.init();
        FabricLib39BlockEntities.init();
        FabricLib39SoundEvents.init();
        FabricCommonEventHandler.initCommon();
        if (Lib39.shouldRegisterExamples()) {
            Lib39.LOGGER.info("[Lib39-Fabric] Registering Examples");
            registerExamples();
        }
        Lib39.LOGGER.info("[Lib39-Fabric] Finished Initializing.");
    }

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

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