无法应用插件[id'forge']

时间:2019-10-10 22:01:07

标签: java gradle minecraft minecraft-forge

这是this question的继续,我的第一个问题已解决,但随后又出现了新的问题。

在其中提到的教程之后,解决了一些错误,当我尝试运行。\ gradlew任务时,现在出现错误:

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\benji\MinecraftWorkspace\forge-1.7.10-10.13.4.1614-1.7.10-src\build.gradle' line: 18

* What went wrong:
A problem occurred evaluating root project 'forge-1.7.10-10.13.4.1614-1.7.10-src'.
> Failed to apply plugin [id 'forge']
   > You must set the Minecraft Version!
      > java.lang.NullPointerException (no error message)

如何设置Minecraft版本? (在这种情况下为1.7.10)

编辑以包含build.gradle:

buildscript {
    repositories {
        mavenCentral()
        maven {
            name = "forge"
            url = "http://files.minecraftforge.net/maven"
        }
        maven {
            name = "sonatype"
            url = "https://oss.sonatype.org/content/repositories/snapshots/"
        }
    }
    dependencies {
        classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
    }
}

apply plugin: 'forge'

version = "1.0"
group= "com.yourname.modid" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "modid"

minecraft {
    version = "1.7.10-10.13.4.1614-1.7.10"
    runDir = "eclipse"
}

dependencies {
    // you may put jars on which you depend on in ./libs
    // or you may define them like so..
    //compile "some.group:artifact:version:classifier"
    //compile "some.group:artifact:version"

    // real examples
    //compile 'com.mod-buildcraft:buildcraft:6.0.8:dev'  // adds buildcraft to the dev env
    //compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env

    // for more info...
    // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
    // http://www.gradle.org/docs/current/userguide/dependency_management.html

}

processResources
{
    // this will ensure that this task is redone when the versions change.
    inputs.property "version", project.version
    inputs.property "mcversion", project.minecraft.version

    // replace stuff in mcmod.info, nothing else
    from(sourceSets.main.resources.srcDirs) {
        include 'mcmod.info'

        // replace version and mcversion
        expand 'version':project.version, 'mcversion':project.minecraft.version
    }

    // copy everything else, thats not the mcmod.info
    from(sourceSets.main.resources.srcDirs) {
        exclude 'mcmod.info'
    }
}

2 个答案:

答案 0 :(得分:1)

pls将插件更新为最新版本。作为参考,请检查此linklink

还尝试删除用户主目录中的.gradle文件夹,然后再次运行。

答案 1 :(得分:0)

我通过安装Forge 1.7.10的“推荐”版本而不是“最新”版本来解决此问题。确实很简单,尽管我已经打过另一个wall