lukflug / PanelStudio

An extensible and customizable GUI API/library to create ClickGUIs, HUDEditors and TabGUIs designed for use in Minecraft utility mods.
https://lukflug.github.io/panelstudio.html
MIT License
309 stars 23 forks source link

ClassNotFoundException when clickgui gets initialized #23

Closed daomephsto closed 3 years ago

daomephsto commented 3 years ago

``Hello, i'm having an issue when trying to initialize the clickgui,i think its a gradle problem. everything works fine on the runClient task but when trying to initialize the client from the jar in the minecraft launcher it crashes with this error: https://pastebin.com/wdqdxha0 This is my build.gradle file:

plugins {
    id 'fabric-loom' version '0.7.27'
    id 'maven-publish'
    id "com.github.johnrengelman.shadow" version "7.0.0"
}

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group

minecraft {
}

repositories {
    mavenLocal()
    mavenLocal()
    jcenter()

    maven {
        url = "https://jitpack.io"
    }

    maven {
        name = 'lukflug'
        url = 'https://lukflug.github.io/maven'
    }
}

dependencies {
    //to change the versions see the gradle.properties file
    minecraft ("com.mojang:minecraft:${project.minecraft_version}")
    mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
    modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

    modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"

    implementation include("com.lukflug:panelstudio:0.1.8")
    modImplementation include("com.lukflug:panelstudio-mc16:0.1.9")

    implementation include('club.minnced:java-discord-rpc:2.0.1')
}

shadowJar{
    dependencies{
        include(dependency("com.lukflug:panelstudio"))
        include(dependency("com.lukflug:panelstudio-mc16"))
        include(dependency('club.minnced:java-discord-rpc:2.0.1'))
    }
}

processResources {
    inputs.property "version", project.version

    filesMatching("fabric.mod.json") {
        expand "version": project.version
    }
}

// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType(JavaCompile).configureEach {
    it.options.encoding = "UTF-8"
    def targetVersion = 8
    if (JavaVersion.current().isJava9Compatible()) {
        it.options.release = targetVersion
    }
}

// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this task, sources will not be generated.
task sourcesJar(type: Jar, dependsOn: classes) {
    classifier = "sources"
    from sourceSets.main.allSource
}

jar {
    from("LICENSE") {
        rename { "${it}_${project.archivesBaseName}"}
    }
}

remapJar {
    dependsOn(shadowJar)
    input.set(shadowJar.archiveFile)
}

java {
    withSourcesJar()
}

// configure the maven publication
publishing {
    publications {
        mavenJava(MavenPublication) {
            // add all the jars that should be included when publishing to maven
            artifact(jar) {
                builtBy remapJar
            }
            artifact("${project.buildDir.absolutePath}/libs/${archivesBaseName}-${project.version}.jar"){
                builtBy remapJar
            }
            artifact(sourcesJar) {
                builtBy remapSourcesJar
            }
        }
    }

    // select the repositories you want to publish to
    repositories {
        // uncomment to publish to the local maven
        // mavenLocal()
    }
}

It works fine in runClient task with panelstudio and it shows up correctly but when building it to jar and launching it it crashes with this error, i checked and deleted the clickgui, then rebuilt the jar and launched and it worked fine again so its probably an issue caused by me importing uncorrectly panelstudio from gradle. would be awesome if you could help me

Mister-Ritom commented 3 years ago

Can you check if your jar file contains panelstudio

daomephsto commented 3 years ago

Hi,thanks for your answer. I decompiled the jar and found this so I guess yeah 2021_08_01_04_26_44_Bytecode_Viewer_2 9 22_https_bytecodeviewer com_https_the bytecode club_

Mister-Ritom commented 3 years ago

Check if you can find mc16 package

daomephsto commented 3 years ago

no i cant, i guess there is something wrong in my build.gradle file but idk what it is

Mister-Ritom commented 3 years ago

Idk then

daomephsto commented 3 years ago

13 is the same issue that Im having right now

lukflug commented 3 years ago

Try using implementation instead of modImplementation

daomephsto commented 3 years ago

I changed modImplementation include("com.lukflug:panelstudio-mc16:0.1.9") for implementation include("com.lukflug:panelstudio-mc16:0.1.9") and I'm getting the same error. (Builds the jar and launches but crashes when it tries to initialize the clickgui, I can tell because in the logs all stuff is working correctly until I do it, runClient still works fine and doesn't crash)

Mister-Ritom commented 3 years ago

Maybe make a custom configuration

daomephsto commented 3 years ago

@RitomG69 I don't know what do you mean with that

Mister-Ritom commented 3 years ago

`buildscript { repositories { maven { url = 'https://files.minecraftforge.net/maven' } maven { url = 'https://repo.spongepowered.org/repository/maven-public/' } }

dependencies {
    classpath 'net.minecraftforge.gradle:ForgeGradle:4.+'
    classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT'
}

}

apply plugin: 'net.minecraftforge.gradle' apply plugin: 'org.spongepowered.mixin'

group = 'me.ritomg' version = '0.2B' archivesBaseName = 'Ananta'

compileJava { sourceCompatibility = targetCompatibility = '1.8' options.encoding = 'UTF-8' }

repositories { maven { url = 'https://repo.spongepowered.org/repository/maven-public/' } maven { url = 'https://impactdevelopment.github.io/maven/' } maven { url = "https://jitpack.io" } maven { url = 'https://lukflug.github.io/maven' } }

minecraft { mappings channel: 'stable', version: '39-1.12' runs { client { workingDirectory project.file('run') property 'fml.coreMods.load', 'me.ritomg.ananta.mixin.CoreMixin' property 'forge.logging.markers', 'REGISTRIES' property 'forge.logging.console.level', 'debug'

        mods {
            ananta {
                source sourceSets.main
            }
        }
    }

    server {
        workingDirectory project.file('run')

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

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

        mods {
            ananta {
                source sourceSets.main
            }
        }
    }
}

}

configurations { //Custom configuration name jarLibs }

dependencies { minecraft 'net.minecraftforge:forge:1.12.2-14.23.5.2854'

//use PS with custom configuration
jarLibs('com.lukflug:panelstudio:0.2.0-SNAPSHOT')
jarLibs('com.lukflug:panelstudio-mc12:0.2.0-SNAPSHOT')

// Add everything in jarLibs to implementation (compile)
implementation configurations.jarLibs

}

processResources { inputs.property "version", project.version

from(sourceSets.main.resources.srcDirs) {
    include 'mcmod.info'
    include 'refmap.ananta.json'

    expand 'version':'0.2'
}

from(sourceSets.main.resources.srcDirs) {
    exclude 'mcmod.info'
}

}

mixin { defaultObfuscationEnv 'searge' add sourceSets.main, 'refmap.ananta.json' }

jar { manifest { attributes( 'MixinConfigs': 'mixins.ananta.json', 'tweakClass': 'org.spongepowered.asm.launch.MixinTweaker', 'TweakOrder': 0, 'FMLCorePluginContainsFMLMod': 'true', 'FMLCorePlugin': 'me.ritomg.ananta.mixin.CoreMixin', 'ForceLoadAsMod': 'true', ) }

// Copy needed libs to jar
from {
    configurations.jarLibs.collect {
        it.isDirectory() ? it : zipTree(it)
    }
}

}` The jarlibs is a custom Configuration and this works without any problem

daomephsto commented 3 years ago

I got this error A problem occurred evaluating root project 'TestProject'.

Could not find method jarLibs() for arguments [com.lukflug:panelstudio:0.1.11] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

Mister-Ritom commented 3 years ago

Did you add this? configurations { //Custom configuration name jarLibs }

Mister-Ritom commented 3 years ago

you don't need shadowjar if you have that

daomephsto commented 3 years ago

yeah, my build.gradle looks like this rn

plugins {
    id 'fabric-loom' version '0.7.27'
    id 'maven-publish'
}

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group

minecraft {
}

repositories {
    mavenLocal()
    mavenLocal()
    jcenter()

    maven {
        url = "https://jitpack.io"
    }

    maven {
        name = 'lukflug'
        url = 'https://lukflug.github.io/maven'
    }
    maven {
        url = 'https://repo.spongepowered.org/repository/maven-public/'
    }
}

dependencies {
    //to change the versions see the gradle.properties file
    minecraft ("com.mojang:minecraft:${project.minecraft_version}")
    mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
    modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

    modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"

    jarLibs("com.lukflug:panelstudio:0.1.11")
    jarLibs("com.lukflug:panelstudio-mc16:0.1.9")

    implementation configurations.jarLibs
}

processResources {
    inputs.property "version", project.version

    filesMatching("fabric.mod.json") {
        expand "version": project.version
    }
}

// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType(JavaCompile).configureEach {
    it.options.encoding = "UTF-8"
    def targetVersion = 8
    if (JavaVersion.current().isJava9Compatible()) {
        it.options.release = targetVersion
    }
}

// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this task, sources will not be generated.
task sourcesJar(type: Jar, dependsOn: classes) {
    classifier = "sources"
    from sourceSets.main.allSource
}

jar {
    from("LICENSE") {
        rename { "${it}_${project.archivesBaseName}"}
    }
}

jar {
    manifest {
        attributes(
                'MixinConfigs': 'mixins.ananta.json',
                'tweakClass': 'org.spongepowered.asm.launch.MixinTweaker',
                'TweakOrder': 0,
                'FMLCorePluginContainsFMLMod': 'true',
                'FMLCorePlugin': 'me.ritomg.ananta.mixin.CoreMixin',
                'ForceLoadAsMod': 'true',
        )
    }

    // Copy needed libs to jar
    from {
        configurations.jarLibs.collect {
            it.isDirectory() ? it : zipTree(it)
        }
    }
}

configurations {
    jarLibs
}

// configure the maven publication
publishing {
    publications {
        mavenJava(MavenPublication) {
            // add all the jars that should be included when publishing to maven
            artifact(jar) {
                builtBy remapJar
            }
            artifact("${project.buildDir.absolutePath}/libs/${archivesBaseName}-${project.version}.jar"){
                builtBy remapJar
            }
            artifact(sourcesJar) {
                builtBy remapSourcesJar
            }
        }
    }

    // select the repositories you want to publish to
    repositories {
        // uncomment to publish to the local maven
        // mavenLocal()
    }
}
Mister-Ritom commented 3 years ago

bro the code i gave is for Forge just add the configuration lines

daomephsto commented 3 years ago

? the config lines are there

Mister-Ritom commented 3 years ago

`plugins { id 'fabric-loom' version '0.7.27' id 'maven-publish' }

sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8

archivesBaseName = project.archives_base_name version = project.mod_version group = project.maven_group

minecraft { }

repositories { mavenLocal() mavenLocal() jcenter()

maven {
    url = "https://jitpack.io"
}

maven {
    name = 'lukflug'
    url = 'https://lukflug.github.io/maven'
}

}

configurations { jarLibs }

dependencies { //to change the versions see the gradle.properties file minecraft ("com.mojang:minecraft:${project.minecraft_version}") mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"

jarLibs("com.lukflug:panelstudio:0.1.11")
jarLibs("com.lukflug:panelstudio-mc16:0.1.9")

implementation configurations.jarLibs

}

processResources { inputs.property "version", project.version

filesMatching("fabric.mod.json") {
    expand "version": project.version
}

}

// ensure that the encoding is set to UTF-8, no matter what the system default is // this fixes some edge cases with special characters not displaying correctly // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html tasks.withType(JavaCompile).configureEach { it.options.encoding = "UTF-8" def targetVersion = 8 if (JavaVersion.current().isJava9Compatible()) { it.options.release = targetVersion } }

// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task // if it is present. // If you remove this task, sources will not be generated. task sourcesJar(type: Jar, dependsOn: classes) { classifier = "sources" from sourceSets.main.allSource }

jar { from("LICENSE") { rename { "${it}_${project.archivesBaseName}"} } }

jar {

// Copy needed libs to jar
from {
    configurations.jarLibs.collect {
        it.isDirectory() ? it : zipTree(it)
    }
}

}

// configure the maven publication publishing { publications { mavenJava(MavenPublication) { // add all the jars that should be included when publishing to maven artifact(jar) { builtBy remapJar } artifact("${project.buildDir.absolutePath}/libs/${archivesBaseName}-${project.version}.jar"){ builtBy remapJar } artifact(sourcesJar) { builtBy remapSourcesJar } } }

// select the repositories you want to publish to
repositories {
    // uncomment to publish to the local maven
    // mavenLocal()
}

}`

Mister-Ritom commented 3 years ago

use this maybe

daomephsto commented 3 years ago

Getting this now org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':jar'. Caused by: org.gradle.api.InvalidUserCodeException: Entry fabric.mod.json is a duplicate but no duplicate handling strategy has been set. Please refer to https://docs.gradle.org/7.0.2/dsl/org.gradle.api.tasks.Copy.html#org.gradle.api.tasks.Copy:duplicatesStrategy for details.

Mister-Ritom commented 3 years ago

Hey first use the old build.gradle that had shadowjar then run gradle shadowjar instead of gradle build. See if that fixes

banimania commented 3 years ago

I already tried that before creating this issue

IUDevman commented 3 years ago

Can confirm this is an issue. Can't find any open source clients that use panelstudio without shadowjar for fabric. I had problems with this in my own client which just resulted in me not using panelstudio for fabric.

Also hi danimania. I also suggest not listening to RitomG unless you want to break your client.

Mister-Ritom commented 3 years ago

Um tensor? Good joke

TechAle commented 3 years ago

wdym good joke lmao

Mister-Ritom commented 3 years ago

Lol