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

Issue when compiling and using the library in my mod #13

Closed ghost closed 3 years ago

ghost commented 3 years ago

Compiling goes fine, but when i try to launch the game, i get a ClassDefNotFound error with the class net.minecraft.gui.screen, which you use in your mod. I somehow cannot get this to work. How can i fix this?

My build script:

plugins {
    id 'fabric-loom' version '0.5-SNAPSHOT'
    id 'maven-publish'
    id "com.github.johnrengelman.shadow" version "6.1.0"
}

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

minecraft {
}

shadowJar {
    dependencies {
        include(dependency('com.lukflug:panelstudio'))
        include(dependency('com.lukflug:panelstudio-mc16'))
        exclude(dependency("com.mojang:minecraft:${project.minecraft_version}"))
    }
}

repositories {
    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}"
    modCompile "com.lukflug:panelstudio-mc16:0.1.9"
    modCompile "com.lukflug:panelstudio:0.1.8"
    modImplementation(include("com.lukflug:panelstudio-mc16:0.1.9"))
    modImplementation(include("com.lukflug:panelstudio:0.1.8"))
}

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

    from(sourceSets.main.resources.srcDirs) {
        include "fabric.mod.json"
        expand "version": project.version
    }

    from(sourceSets.main.resources.srcDirs) {
        exclude "fabric.mod.json"
    }
}

// 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) {
    options.encoding = "UTF-8"
}

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

// 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()
    }
}

Notable to mention: Fabric places both libs in the jars dir in META-INF. This may be part of the issue, but i dont know how to compile it otherwise. The shadowjar method you list in the readme includes the mappings and the remapped classes, so that wont work.

ghost commented 3 years ago

nvm fixed

Whop42 commented 3 years ago

@constantinDev But how did you fix it