package top.leisuretimedock.dglabgame;

import com.mojang.logging.LogUtils;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import top.leisuretimedock.dglabgame.config.ClientConfig;
import top.leisuretimedock.dglabgame.config.CommonConfig;
import top.leisuretimedock.dglabgame.core.network.DLGNetworkHandler;


@Mod(DGLabGame.MOD_ID)
public class DGLabGame {
    public static final String MOD_ID = "dglabgame";
    private static final Logger LOGGER = LogUtils.getLogger();
    public static Logger getLogger() {
        return LOGGER;
    }
    public DGLabGame() {
        DLGNetworkHandler.register();
        ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, CommonConfig.SPEC);
        ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, ClientConfig.SPEC);
    }
    @Contract("_ -> new")
    public static @NotNull ResourceLocation rl(String path) {
        return new ResourceLocation(MOD_ID, path);
    }
    @Contract("_, _ -> new")
    public static @NotNull ResourceLocation rl(String modId, String path) {
        return new ResourceLocation(modId, path);
    }
    @Contract("_ -> new")
    public static @NotNull ResourceLocation mrl(String path) {
        return new ResourceLocation(path);
    }
    /**
     * The type Mod info.
     */
    public static class ModInfo {
        /**
         * The constant VERSION.
         */
        public static final String VERSION;

        static {
            // 从 ModList 获取当前 ModContainer 的元数据
            VERSION = ModList.get()
                    .getModContainerById(MOD_ID)
                    .map(c -> c.getModInfo().getVersion().toString())
                    .orElse("UNKNOWN");
        }
    }
}
