You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

1.12.2 Forge模组构建时mcmod.info未被Gradle识别打包问题求助

问题解决方案

1. 修正ForgeGradle版本

1.12.2版本模组不兼容你当前使用的5.1+版本ForgeGradle,该版本仅适配1.17及以上的MC版本,你需要将buildscript中的dependencies配置修改为对应3.x版本:

dependencies {
    classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.0.+', changing: true
}

2. 新增资源变量替换配置

你当前没有开启Gradle的资源占位符替换功能,导致mcmod.info中的${version}、${mcversion}变量无法被正确解析,也会触发打包识别异常,在build.gradle中添加如下配置段:

processResources {
    // 替换mcmod.info中的占位符
    filesMatching('mcmod.info') {
        expand 'version': project.version, 'mcversion': '1.12.2'
    }
    // 保留其他资源文件不被修改
    includeEmptyDirs = false
}

3. 验证文件存放路径

确认你的mcmod.info直接存放在src/main/resources根目录下,不要放入META-INF文件夹内,1.12.2版本的mcmod.info规范要求放在资源根目录。

4. 可选兼容方案(不换ForgeGradle版本)

如果你坚持使用当前5.1+版本ForgeGradle,可以在jar配置段中手动指定包含mcmod.info文件:

jar {
    from('src/main/resources') {
        include 'mcmod.info'
    }
    // 原有manifest配置保持不变
    manifest {
        attributes([
                "Specification-Title"     : "runetech",
                "Specification-Vendor"    : "Kital_Stargazer",
                "Specification-Version"   : "1",
                "Implementation-Title"    : project.name,
                "Implementation-Version"  : project.jar.archiveVersion,
                "Implementation-Vendor"   : "Kital_Stargazer",
                "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
        ])
    }
}

5. 重新构建项目

执行./gradlew clean build命令清理旧构建缓存并重新打包,构建完成后打开生成的jar文件,确认mcmod.info已出现在jar根目录,且内部的变量占位符已被替换为对应实际值。


内容的提问来源于stack exchange,提问作者Tuvanen Kiruitsu

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.24 14:36:04