Curios API (Forge/NeoForge)

Curios API (Forge/NeoForge)

204M Downloads

[Bug]: Mixin issue in the 1.20.1 forge development environment

CuBr202 opened this issue ยท 2 comments

commented

Version

minecraft_version=1.20.1
forge_version=47.4.0
curios_version=5.12.1+1.20.1
jei_version=15.20.0.106

Description

Hello! I'm new in MC mod development, and I encountered a problem when I'm making my mod based on curios api.
I added the repository, mixin and dependencies in the build.gradle according to the guide:

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

version = mod_version
group = mod_group_id

base {
    archivesName = mod_id
}


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 {
    mappings channel: mapping_channel, version: mapping_version
    copyIdeResources = true
    runs {
        configureEach {
            workingDirectory project.file('run')
            property 'forge.logging.markers', 'REGISTRIES'
            property 'forge.logging.console.level', 'debug'

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

        client {
            property 'forge.enabledGameTestNamespaces', mod_id
            property 'mixin.env.remapRefMap', 'true'
            property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
        }

        server {
            property 'forge.enabledGameTestNamespaces', mod_id
            property 'mixin.env.remapRefMap', 'true'
            property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
            args '--nogui'
        }

        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 {
        name = "Curios"
        url = uri("https://maven.theillusivec4.top/")
    }
    maven {
    // location of the maven that hosts JEI files before January 2023
    name = "Progwml6's maven"
    url = "https://dvs1.progwml6.com/files/maven/"
    }
    maven {
    // location of the maven that hosts JEI files since January 2023
    name = "Jared's maven"
    url = "https://maven.blamejared.com/"
    }
    maven {
    // location of a maven mirror for JEI files, as a fallback
    name = "ModMaven"
    url = "https://modmaven.dev"
    }
}

dependencies {
    minecraft "net.minecraftforge:forge:${mc_version}-${forge_version}"

    annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'

      // compile against the JEI API but do not include it at runtime
    compileOnly(fg.deobf("mezz.jei:jei-${mc_version}-forge-api:${jei_version}"))
    // at runtime, use the full JEI jar for Forge
    runtimeOnly(fg.deobf("mezz.jei:jei-${mc_version}-forge:${jei_version}"))

    compileOnly "top.theillusivec4.curios:curios-forge:${curios_version}:api"
    runtimeOnly "top.theillusivec4.curios:curios-forge:${curios_version}"
}

/*
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]
    }
}*/


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")
        ])
    }


    finalizedBy '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
}

Gradle and Java did run properly, and the mod is successfully downloaded.
But when doing the runClient task, the game would soon crash due to the following reason:

Mixin apply failed curios.mixins.json:MixinInventory -> net.minecraft.world.entity.player.Inventory: org.spongepowered.asm.mixin.transformer.throwables.InvalidMixinException @Shadow field f_35978_ was not located in the target class net.minecraft.world.entity.player.Inventory. Using refmap curios.refmap.json

I can see that it's caused by MixinInventory in curios.mixins.json, but I didn't know how to solve it.
There're similar issues before, but their solutions simply didn't work.
I'm really having a hard time dealing with it.

Log

This is the full log generated by runClient task.
https://mclo.gs/ZOURlTO

commented

I noticed that I hadn't add mixin into data, so I modified this part:

        data {
            property 'mixin.env.remapRefMap', 'true'
            property 'mixin.env.refMapRemappingFile', "${buildDir}/createSrgToMcp/output.srg"
            // 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/')
        }

But after cleaning up and rebuilding, it still come up with the same error:

Mixin apply failed curios.mixins.json:MixinInventory -> net.minecraft.world.entity.player.Inventory: org.spongepowered.asm.mixin.transformer.throwables.InvalidMixinException @Shadow field f_35978_ was not located in the target class net.minecraft.world.entity.player.Inventory. Using refmap curios.refmap.json
commented

In your dependencies block you have these lines:

compileOnly "top.theillusivec4.curios:curios-forge:${curios_version}:api"
runtimeOnly "top.theillusivec4.curios:curios-forge:${curios_version}"

These are missing fg.deobf surrounding them, such as what you have for JEI. Add these to both these lines and then recompile and it should resolve the issue.