Jump to content

Recommended Posts

Posted

I'm currently making a mod that uses discord jda, but I'm running into some issues when running the mod.

 

When I run it through eclipse, it works just fine - no problems at all.

When I run gradlew build, export it with all the dependency jars in the libs folder (picture below), and then run minecraft, it gives me this:

[19:03:17] [Client thread/ERROR]: Caught exception from laggview
java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
	at net.dv8tion.jda.core.utils.JDALogger.<clinit>(JDALogger.java:52) ~[JDALogger.class:?]
	at net.dv8tion.jda.core.entities.impl.JDAImpl.<clinit>(JDAImpl.java:58) ~[JDAImpl.class:?]
	at net.dv8tion.jda.core.JDABuilder.buildAsync(JDABuilder.java:643) ~[JDABuilder.class:?]
	at net.dv8tion.jda.core.JDABuilder.buildBlocking(JDABuilder.java:701) ~[JDABuilder.class:?]
	at net.dv8tion.jda.core.JDABuilder.buildBlocking(JDABuilder.java:730) ~[JDABuilder.class:?]
	at com.thelagg.laggview.DiscordListener.<init>(DiscordListener.java:41) ~[DiscordListener.class:?]
	at com.thelagg.laggview.LaggView.init(LaggView.java:75) ~[LaggView.class:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_25]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_25]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_25]
	at java.lang.reflect.Method.invoke(Method.java:483) ~[?:1.8.0_25]
	at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:560) ~[forge-1.8.9-11.15.1.2318-1.8.9.jar:?]
	at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source) ~[?:?]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_25]
	at java.lang.reflect.Method.invoke(Method.java:483) ~[?:1.8.0_25]
	at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?]
	at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?]
	at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?]
	at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?]
	at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?]
	at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:211) ~[forge-1.8.9-11.15.1.2318-1.8.9.jar:?]
	at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:189) ~[forge-1.8.9-11.15.1.2318-1.8.9.jar:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_25]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_25]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_25]
	at java.lang.reflect.Method.invoke(Method.java:483) ~[?:1.8.0_25]
	at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?]
	at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?]
	at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?]
	at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?]
	at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?]
	at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:118) [LoadController.class:?]
	at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:737) [Loader.class:?]
	at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:310) [FMLClientHandler.class:?]
	at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:495) [ave.class:?]
	at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:329) [ave.class:?]
	at net.minecraft.client.main.Main.main(SourceFile:124) [Main.class:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_25]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_25]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_25]
	at java.lang.reflect.Method.invoke(Method.java:483) ~[?:1.8.0_25]
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
	at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:101) ~[launchwrapper-1.12.jar:?]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_25]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_25]
	... 43 more

 

My Dependencies:

QyNnAAgpQL_gibIPLNrtNw.png

 

I've also tried adding the JDA to my build.gradle by adding:

repositories {
	jcenter()
}
dependencies {
	compile 'net.dv8tion:JDA:3.5.0_327'  
}

But that gave me the same error, so I commented that out for now. 

 

I think it should work properly because when I look inside the jar with WinRAR, it shows me that org.slf4j.LoggerFactory exists:

Lzgi1rs4RMWnO8piMUJ9aw.png

 

I'm thinking I must be doing something wrong with exporting the mod because it runs fine from eclipse - it just doesn't run when I put it in my .minecraft/mods folder. 

I'd appreciate any help, thanks in advance! :)

 

P.S. I'm using Forge 1.8.9 latest version - I'm not sure if that's a problem. The reason I'm using that over 1.11 is because the server my mod's designed for runs only 1.8.9.

Hi

:D

Posted (edited)
1 hour ago, loordgek said:

I don't quite understand what you mean by this, am I supposed to use shadow to insert org.slf4j into the existing jar? I've already looked at the jar from inside winrar and org.slf4j seems to be there - it just doesn't seem to be compiled at runtime. Could you explain a bit more?

Edited by Lagg

Hi

:D

Posted (edited)

Ok so I've done a bit more stuff with the gradle shadow plugin @loordgek posted, but now I have an issue with minecraft obfuscation.

 

When I run gradlew build with this in my build.gradle:

buildscript {
    repositories {
        jcenter()
        maven {
            name = "forge"
            url = "http://files.minecraftforge.net/maven"
        }
    }
    dependencies {
        classpath 'net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT'
        classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.2'
    }
}

apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'com.github.johnrengelman.plugin-shadow'
apply plugin: 'java'

version = "1.0"
group= "com.thelagg.laggview"
archivesBaseName = "laggview"
sourceCompatibility = 1.8
targetCompatibility = 1.8

project.tasks.build.dependsOn project.tasks.shadowJar

minecraft {
    version = "1.8.9-11.15.1.2318-1.8.9"
    runDir = "run"
    mappings = "stable_20"
}

shadowJar {
   baseName = 'laggview-shadow'
   classifier = null
   version = 1.0
   configurations = [project.configurations.compile]
}

repositories {
	jcenter()
}

dependencies {
	//both my dependencies are in the ./libs folder
}

processResources
{
    inputs.property "version", project.version
    inputs.property "mcversion", project.minecraft.version
    from configurations.compile.collect { zipTree it }
    from(sourceSets.main.resources.srcDirs) {
        include 'mcmod.info'
        expand 'version':project.version, 'mcversion':project.minecraft.version
    }
    from(sourceSets.main.resources.srcDirs) {
        exclude 'mcmod.info'
    }
}

 

The shadow-jar seems to look good when I open it with luyten (java deobfuscator):

_uyGn4J6S_OSnY3vBpLK7Q.png

 

The regular jar hasn't changed at all (it still compiles the dependencies, but doesn't shadow them). I've tried putting the shadow jar into my mods folder to try and run that, but it gave me an error that it could not find a method Minecraft.getMinecraft() - the shadowed Jar doesn't obfuscate any of the fields or methods inside it (picture below)

 

laggview-shadow-1.0.jar

tCLZSYbuT-qYDiduYNBvug.png

 

laggview-1.0.jar

j2PCpufRS4_8uWpdDkczHQ.png

 

So, I'm looking to do either one of 2 things:

  1. Obfuscate the shadow jar like I would with the normal jar
  2. shadow the normal jar's dependencies

I just have no idea how to do either of those things... 

If anybody could shed some light on the topic, I would appreciate it. Thanks!

Edited by Lagg
grammar

Hi

:D

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.