Jump to content

[1.15.2][Solved] Embedding library in mod


Papa_Prime

Recommended Posts

Hello, I am trying to embed a library into my mod. This is the documentation I am using which also seems out of date https://forgegradle.readthedocs.io/en/latest/user-guide/shading/.

This is my build.gradle:

buildscript {
    repositories {
        maven { url = 'https://files.minecraftforge.net/maven' }
        maven {
            url = "https://repo.spongepowered.org/maven"
        }
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
        classpath 'org.spongepowered:mixingradle:0.6-SNAPSHOT'
    }
}
plugins {
    id 'org.spongepowered.plugin' version '0.6'
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'

version = '1.0'
group = 'net.papaprime.animationcore'
archivesBaseName = 'animationcore'

sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'

repositories {
    jcenter()
    maven {
        name = "spongepowered"
        url = "https://repo.spongepowered.org/maven"
    }
}

configurations {
    shade
    compile.extendsFrom(shade)
}

minecraft {

    mappings channel: 'snapshot', version: '20200514-1.15.1'

    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'

            mods {
                animationcore {
                    source sourceSets.main
                }
            }
        }

        server {
            workingDirectory project.file('run')

            property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'

            property 'forge.logging.console.level', 'debug'

            mods {
                animationcore {
                    source sourceSets.main
                }
            }
        }

        data {
            workingDirectory project.file('run')

            property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'

            property 'forge.logging.console.level', 'debug'

            args '--mod', 'animationcore', '--all', '--output', file('src/generated/resources/')

            mods {
                animationcore {
                    source sourceSets.main
                }
            }
        }
    }
}

dependencies {
    minecraft 'net.minecraftforge:forge:1.15.2-31.2.8'
    // For more info...
    // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
    // http://www.gradle.org/docs/current/userguide/dependency_management.html

    shade("org.spongepowered:mixin:0.8")
    compile("org.spongepowered:mixin:0.8")
}

jar {
    manifest {
        attributes([
                "TweakClass": "org.spongepowered.asm.launch.MixinTweaker",
                "TweakOrder": 0,
            "Specification-Title": "animationcore",
            "Specification-Vendor": "animationcoresareus",
            "Specification-Version": "1", // We are version 1 of ourselves
            "Implementation-Title": project.name,
            "Implementation-Version": "${version}",
            "Implementation-Vendor" :"animationcoresareus",
            "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
        ])
    }
    from configurations.shade.copyRecursive().setTransitive(false).each { artifact ->
        from (zipTree(artifact))
    }
}

jar.finalizedBy('reobfJar')

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

    }
}

after running gradlew build it does produce a jar with the library embedded in it. This jar crashes instantly in a release version of minecraft. This is the crash report found in the log:

[07Jun2020 18:00:44.388] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: org.spongepowered.asm.launch.MixinInitialisationError: Mixin Launch Plugin Service could not be located
[07Jun2020 18:00:44.388] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: 	at org.spongepowered.asm.launch.MixinTransformationService.initialize(MixinTransformationService.java:76)
[07Jun2020 18:00:44.388] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: 	at cpw.mods.modlauncher.TransformationServiceDecorator.onInitialize(TransformationServiceDecorator.java:68)
[07Jun2020 18:00:44.389] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: 	at cpw.mods.modlauncher.TransformationServicesHandler.lambda$initialiseTransformationServices$7(TransformationServicesHandler.java:107)
[07Jun2020 18:00:44.389] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: 	at cpw.mods.modlauncher.TransformationServicesHandler$$Lambda$85/2109798150.accept(Unknown Source)
[07Jun2020 18:00:44.389] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: 	at java.util.HashMap$Values.forEach(HashMap.java:972)
[07Jun2020 18:00:44.389] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: 	at cpw.mods.modlauncher.TransformationServicesHandler.initialiseTransformationServices(TransformationServicesHandler.java:107)
[07Jun2020 18:00:44.390] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: 	at cpw.mods.modlauncher.TransformationServicesHandler.initializeTransformationServices(TransformationServicesHandler.java:59)
[07Jun2020 18:00:44.390] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: 	at cpw.mods.modlauncher.Launcher.run(Launcher.java:75)
[07Jun2020 18:00:44.390] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: 	at cpw.mods.modlauncher.Launcher.main(Launcher.java:65)

Any help would be appreciated

Edited by Papa_Prime
Link to comment
Share on other sites

I have done a bit of digging and managed to find a solution. This is the build script as I have it now:

buildscript {
    repositories {
        maven { url = 'https://files.minecraftforge.net/maven' }
        maven {
            url = "https://repo.spongepowered.org/maven"
        }
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
        classpath 'org.spongepowered:mixingradle:0.6-SNAPSHOT'
    }
}
plugins {
    id 'org.spongepowered.plugin' version '0.6'
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'

version = '1.0'
group = 'net.papaprime.animationcore'
archivesBaseName = 'animationcore'

sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'

repositories {
    jcenter()
    maven {
        name = "spongepowered"
        url = "https://repo.spongepowered.org/maven"
    }
}

configurations {
    inJar
}
configurations.compile.extendsFrom(configurations.inJar)

minecraft {

    mappings channel: 'snapshot', version: '20200514-1.15.1'

    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'

            mods {
                animationcore {
                    source sourceSets.main
                }
            }
        }

        server {
            workingDirectory project.file('run')

            property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'

            property 'forge.logging.console.level', 'debug'

            mods {
                animationcore {
                    source sourceSets.main
                }
            }
        }

        data {
            workingDirectory project.file('run')

            property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'

            property 'forge.logging.console.level', 'debug'

            args '--mod', 'animationcore', '--all', '--output', file('src/generated/resources/')

            mods {
                animationcore {
                    source sourceSets.main
                }
            }
        }
    }
}

dependencies {
    minecraft 'net.minecraftforge:forge:1.15.2-31.2.8'
    // For more info...
    // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
    // http://www.gradle.org/docs/current/userguide/dependency_management.html

    inJar("org.spongepowered:mixin:0.8")
}

jar {
    manifest {
        attributes([
                "TweakClass": "org.spongepowered.asm.launch.MixinTweaker",
                "TweakOrder": 0,
            "Specification-Title": "animationcore",
            "Specification-Vendor": "animationcoresareus",
            "Specification-Version": "1", // We are version 1 of ourselves
            "Implementation-Title": project.name,
            "Implementation-Version": "${version}",
            "Implementation-Vendor" :"animationcoresareus",
            "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
            "ContainedDeps": "mixin-0.8.jar"
        ])
    }
    from(configurations.inJar) {
        into 'META-INF/libraries'
    }
}

jar.finalizedBy('reobfJar')

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

    }
}

This appears to be working.

  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.