mouse0w0 / forge-mixin-example

An example for using Mixin in Minecraft Forge 1.12.2 & 1.8.9
The Unlicense
113 stars 19 forks source link

The code can't find the Mixin #17

Closed xiaohuigehhy closed 1 month ago

xiaohuigehhy commented 2 months ago

I have built the mixingradle using the mixingradle method, but when I am writing code, it cannot search for mixin annotations and other files.

Windows, forge 1.12.2-14.23.5.2859 mixin 0.8.3

I check the External Libraries in the Intellij Idea, it hasn't "org.spongepowered........."

代码找不到下载的Mixin文件

mouse0w0 commented 2 months ago

这可能是网络问题,请多刷新几次项目和IDEA。

xiaohuigehhy commented 1 month ago

程序把mixin文件下载到了本地,但是Intellij Idea没法把这个mixin的jar文件导入进来并让程序识别

mouse0w0 commented 1 month ago

如果gradlew build能够正常构建出Mod就是IDEA的问题,尝试File -> Invalidate Cache... -> 勾选所有选项 -> Invalidate and Restart清除缓存。

xiaohuigehhy commented 1 month ago

Configure project : MixinGradle did not locate the diffplug APT plugin, skipping eclipse task configuration New Dep: net.minecraftforge:forge:1.12.2-14.23.5.2859_mapped_snapshot_20171003-1.12

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/4.9/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 14s

xiaohuigehhy commented 1 month ago

日志里面 刷新gradlew

xiaohuigehhy commented 1 month ago

buildscript { repositories { maven { url = 'https://maven.minecraftforge.net/' } mavenCentral() } dependencies { classpath 'net.minecraftforge.gradle:ForgeGradle:3.+' classpath 'org.spongepowered:mixingradle:0.7.+' } }

apply plugin: 'net.minecraftforge.gradle' // Only edit below this line, the above code adds and enables the necessary things for Forge to be setup. apply plugin: 'eclipse' apply plugin: 'maven-publish' apply plugin: 'org.spongepowered.mixin'

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

sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.

minecraft { // The mappings can be changed at any time, and must be in the following format. // snapshotYYYYMMDD Snapshot are built nightly. // stable# Stables are built at the discretion of the MCP team. // 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: 'snapshot', version: '20171003-1.12' mappings channel: 'snapshot', version: '20171003-1.12' // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.

// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')

// Default run configurations.
// These can be tweaked, removed, or duplicated as needed.
runs {
    client {
        workingDirectory project.file('run')

        // Recommended logging data for a userdev environment
        property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'

        // Recommended logging level for the console
        property 'forge.logging.console.level', 'debug'

    }

    server {

        // Recommended logging data for a userdev environment
        property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'

        // Recommended logging level for the console
        property 'forge.logging.console.level', 'debug'

    }
}

}

dependencies { // Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed // that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied. // The userdev artifact is a special name and will get all sorts of transformations applied to it. minecraft 'net.minecraftforge:forge:1.12.2-14.23.5.2859'

// 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

// The 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime.
// provided 'com.mod-buildcraft:buildcraft:6.0.8:dev'

// These dependencies get remapped to your current MCP mappings
// deobf 'com.mod-buildcraft:buildcraft:6.0.8:dev'

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

}

mixin { add sourceSets.main, "mixins.xusmod.refmap.json" config "mixins.xusmod.json" }

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

// Example configuration to allow publishing using the maven-publish task // This is the preferred method to reobfuscate your jar file jar.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 //publish.dependsOn('reobfJar')

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

task copyTestResources(type: Copy) { from "${projectDir}/src/main/resources" into "${buildDir}/classes/java/main" }

xiaohuigehhy commented 1 month ago

内部

xiaohuigehhy commented 1 month ago

forge 版本 net.minecraftforge:forge:1.12.2-14.23.5.2859

mouse0w0 commented 1 month ago

很显然你使用的不是本仓库,dependencies中缺少Mixin的依赖引入。如果你是在本人的博客查看的如何在Minecraft Forge中使用Mixin,它仅仅适用于1.17.1及以上版本的Forge。如果你要在1.12.2使用Mixin,请使用本仓库作为模板创建项目。

xiaohuigehhy commented 1 month ago

但是仓库的forge版本和我所使用的版本不匹配啊

xiaohuigehhy commented 1 month ago

而且仓库里没有一些注释说明,很难学习到底是使用了什么方法来添加mixin...

mouse0w0 commented 1 month ago

在本仓库内的gradle.properties中修改你的forge版本。

xiaohuigehhy commented 1 month ago

我是在一个正在开发的模组中使用mixin

xiaohuigehhy commented 1 month ago

而且像是apply plugin这样的语句在我的forge版本里的gradlew文件中会报错

mouse0w0 commented 1 month ago

好的,但这不在本仓库的负责范围内,请移步到其他社区咨询。