2301_76275164 2025-07-23 01:06 采纳率: 83.3%
浏览 38
已结题

https://libraries.minecraft.net/网站失效如何解决?

用IDEA构建minecraft1.19.2forgeMDK时报错:

An exception occurred applying plugin request [id: 'net.minecraftforge.gradle', version: '[6.0,6.2)']
> Failed to apply plugin 'net.minecraftforge.gradle'.
   > Failed to validate certificate for host 'https://libraries.minecraft.net/'. To disable this check, re-run with '-Dnet.minecraftforge.gradle.check.certs=false'.


点击https://libraries.minecraft.net/网站依旧报错
要如何解决?
gardle如下

plugins {
    id 'eclipse'
    id 'idea'
    id 'maven-publish'
    id 'net.minecraftforge.gradle' version '[6.0,6.2)'
}

version = mod_version
group = mod_group_id

base {
    archivesName = mod_id
}

// Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17.
java.toolchain.languageVersion = JavaLanguageVersion.of(17)

println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}"
minecraft {
    // The mappings can be changed at any time and must be in the following format.
    // Channel:   Version:
    // official   MCVersion             Official field/method names from Mojang mapping files
    // parchment  YYYY.MM.DD-MCVersion  Open community-sourced parameter names and javadocs layered on top of official
    //
    // You must be aware of the Mojang license when using the 'official' or 'parchment' mappings.
    // See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
    //
    // Parchment is an unofficial project maintained by ParchmentMC, separate from MinecraftForge
    // Additional setup is needed to use their mappings: https://github.com/ParchmentMC/Parchment/wiki/Getting-Started
    //
    // Use non-default mappings at your own risk. They may not always work.
    // Simply re-run your setup task after changing the mappings to update your workspace.
    mappings channel: mapping_channel, version: mapping_version

    // When true, this property will have all Eclipse/IntelliJ IDEA run configurations run the "prepareX" task for the given run configuration before launching the game.
    // In most cases, it is not necessary to enable.
    // enableEclipsePrepareRuns = true
    // enableIdeaPrepareRuns = true

    // This property allows configuring Gradle's ProcessResources task(s) to run on IDE output locations before launching the game.
    // It is REQUIRED to be set to true for this template to function.
    // See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
    copyIdeResources = true

    // When true, this property will add the folder name of all declared run configurations to generated IDE run configurations.
    // The folder name can be set on a run configuration using the "folderName" property.
    // By default, the folder name of a run configuration is the name of the Gradle project containing it.
    // generateRunFolders = true

    // This property enables access transformers for use in development.
    // They will be applied to the Minecraft artifact.
    // The access transformer file can be anywhere in the project.
    // However, it must be at "META-INF/accesstransformer.cfg" in the final mod jar to be loaded by Forge.
    // This default location is a best practice to automatically put the file in the right place in the final jar.
    // See https://docs.minecraftforge.net/en/latest/advanced/accesstransformers/ for more information.
    // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')

    // Default run configurations.
    // These can be tweaked, removed, or duplicated as needed.
    runs {
        // applies to all the run configs below
        configureEach {
            workingDirectory project.file('run')

            // Recommended logging data for a userdev environment
            // The markers can be added/remove as needed separated by commas.
            // "SCAN": For mods scan.
            // "REGISTRIES": For firing of registry events.
            // "REGISTRYDUMP": For getting the contents of all registries.
            property 'forge.logging.markers', 'REGISTRIES'

            // Recommended logging level for the console
            // You can set various levels here.
            // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
            property 'forge.logging.console.level', 'debug'

            // Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
            property 'forge.enabledGameTestNamespaces', mod_id

            mods {
                "${mod_id}" {
                    source sourceSets.main
                }
            }
        }

        client {
            // Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
            property 'forge.enabledGameTestNamespaces', mod_id
        }

        server {
            property 'forge.enabledGameTestNamespaces', mod_id
            args '--nogui'
        }

        // This run config launches GameTestServer and runs all registered gametests, then exits.
        // By default, the server will crash when no gametests are provided.
        // The gametest system is also enabled by default for other run configs under the /test command.
        gameTestServer {
            property 'forge.enabledGameTestNamespaces', mod_id
        }

        data {
            // example of overriding the workingDirectory set in configureEach above
            workingDirectory project.file('run-data')

            // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
            args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
        }
    }
}

// Include resources generated by data generators.
sourceSets.main.resources { srcDir 'src/generated/resources' }

repositories {
    maven {
        url "https://cursemaven.com"
    }
    // Put repositories for dependencies here
    // ForgeGradle automatically adds the Forge maven and Maven Central for you

    // If you have mod jar dependencies in ./libs, you can declare them as a repository like so:
    // flatDir {
    //     dir 'libs'
    // }
}

dependencies {
    // Specify the version of Minecraft to use.
    // Any artifact can be supplied so long as it has a "userdev" classifier artifact and is a compatible patcher artifact.
    // The "userdev" classifier will be requested and setup by ForgeGradle.
    // If the group id is "net.minecraft" and the artifact id is one of ["client", "server", "joined"],
    // then special handling is done to allow a setup of a vanilla dependency without the use of an external repository.
    minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"

    // Real mod deobf dependency examples - these get remapped to your current mappings
    // compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") // Adds JEI API as a compile dependency
    // runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}") // Adds the full JEI mod as a runtime dependency
    // implementation fg.deobf("com.tterrag.registrate:Registrate:MC${mc_version}-${registrate_version}") // Adds registrate as a dependency

    // Example mod dependency using a mod jar from ./libs with a flat dir repository
    // This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar
    // The group id is ignored when searching -- in this case, it is "blank"
    // implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}")

    // For more info:
    // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
    // http://www.gradle.org/docs/current/userguide/dependency_management.html
}
// This block of code expands all declared replace properties in the specified resource targets.
// A missing property will result in an error. Properties are expanded using ${} Groovy notation.
// When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments.
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
tasks.named('processResources', ProcessResources).configure {
    var replaceProperties = [
            minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range,
            forge_version: forge_version, forge_version_range: forge_version_range,
            loader_version_range: loader_version_range,
            mod_id: mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
            mod_authors: mod_authors, mod_description: mod_description,
    ]
    inputs.properties replaceProperties

    filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) {
        expand replaceProperties + [project: project]
    }
}

// Example for how to get properties into the manifest for reading at runtime.
tasks.named('jar', Jar).configure {
    manifest {
        attributes([
                'Specification-Title'     : mod_id,
                'Specification-Vendor'    : mod_authors,
                'Specification-Version'   : '1', // We are version 1 of ourselves
                'Implementation-Title'    : project.name,
                'Implementation-Version'  : project.jar.archiveVersion,
                'Implementation-Vendor'   : mod_authors,
                'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
        ])
    }

    // This is the preferred method to reobfuscate your jar file
    finalizedBy 'reobfJar'
}

// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing:
// tasks.named('publish').configure {
//     dependsOn 'reobfJar'
// }

publishing {
    publications {
        register('mavenJava', MavenPublication) {
            artifact jar
        }
    }
    repositories {
        maven {
            url "file://${project.projectDir}/mcmodsrepo"
        }
    }
}

tasks.withType(JavaCompile).configureEach {
    options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
}


  • 写回答

3条回答 默认 最新

  • 檀越@新空间 2025-07-23 01:07
    关注

    上午好☀️☀️☀️️
    本答案参考通义千问

    当您遇到 https://libraries.minecraft.net/ 网站失效的问题时,这通常是因为该网站已不再维护或被移除。在使用 Forge MDK 1.19.2 时,某些依赖项可能仍然尝试从该地址下载资源,从而导致构建失败。


    ✅ 解决方案

    1. 修改 Gradle 配置以绕过证书验证(临时解决方案)

    由于错误提示中提到“证书验证失败”,您可以暂时禁用证书检查来继续构建:

    🔧 操作步骤:

    • 在运行 Gradle 构建命令时添加参数:
      ./gradlew build -Dnet.minecraftforge.gradle.check.certs=false
      

    注意: 这是一个临时性解决方案,不建议长期使用,因为它会降低安全性。


    2. 替换 libraries.minecraft.net 的源为官方仓库(推荐)

    Minecraft 的依赖库已经迁移到了 Maven CentralForge 的官方仓库,因此我们可以将 repositories 配置改为使用这些可靠的源。

    📝 修改后的 build.gradle 示例:

    buildscript {
        repositories {
            mavenCentral()
            maven { url = 'https://maven.minecraftforge.net' }
        }
    
        dependencies {
            classpath 'net.minecraftforge.gradle:ForgeGradle:6.0.38'
        }
    }
    
    plugins {
        id 'eclipse'
        id 'idea'
        id 'maven-publish'
        id 'net.minecraftforge.gradle' version '[6.0,6.2)'
    }
    
    version = mod_version
    group = mod_group_id
    
    base {
        archivesName = mod_id
    }
    
    java.toolchain.languageVersion = JavaLanguageVersion.of(17)
    
    minecraft {
        mappings channel: mapping_channel, version: mapping_version
        // 其他配置...
    }
    

    重点说明:

    • 将原来的 repositories 移除或替换为 mavenCentral()maven { url = 'https://maven.minecraftforge.net' }
    • 使用 net.minecraftforge.gradle 插件的版本应确保是兼容的(如 6.0.38

    3. 手动下载缺失的依赖并本地安装(高级)

    如果某些依赖确实无法从 Maven Central 或 Forge 官方仓库获取,可以手动下载 JAR 文件,并将其放入本地 Maven 仓库。

    🛠 步骤:

    1. 访问 Maven CentralForge 官方仓库
    2. 找到你需要的依赖(例如:net.minecraftforge:forge:1.19.2-41.0.105
    3. 下载 .jar 文件
    4. 使用以下命令安装到本地 Maven 仓库:
      mvn install:install-file -Dfile=path/to/your-jar.jar -DgroupId=net.minecraftforge -DartifactId=forge -Dversion=1.19.2-41.0.105 -Dpackaging=jar
      

    注意: 需要先安装 Maven 并配置环境变量。


    4. 更新 Forge 版本(如有需要)

    如果您使用的 Forge 版本较旧,建议升级到更新的版本(如 41.0.105),因为旧版本可能对网络资源的访问方式已过时。

    🔄 更新步骤:

    • 访问 Forge 官网
    • 下载最新版的 forge-1.19.2-41.0.105-installer-win.exe
    • 使用其生成的 build.gradle 文件作为模板

    ✅ 总结

    | 问题 | 解决方案 | |------|----------| | libraries.minecraft.net 失效 | 替换为 mavenCentral()maven { url = 'https://maven.minecraftforge.net' } | | 证书验证失败 | 添加 -Dnet.minecraftforge.gradle.check.certs=false 参数 | | 依赖缺失 | 手动下载并安装到本地 Maven 仓库 | | 旧版本问题 | 升级到最新的 Forge 版本 |


    🧩 附加建议

    • 如果你使用的是 IDEA,建议在项目设置中检查 Gradle JVM 是否为 Java 17。
    • 确保你的 Java 环境JDK 17,并且 JAVA_HOME 环境变量指向正确的路径。
    • 如果仍然报错,请提供完整的错误日志,以便进一步排查。

    如果你有具体的错误日志或代码片段,我可以帮助你更精准地定位问题!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 7月23日
  • 已采纳回答 7月23日
  • 创建了问题 7月23日