1. wiII

    wiII Active Member

    WillOCN
    MVP+
    Bridgers BRIDGE
    Member
    Messages:
    473
    Hi, I'm trying to make a forge mod that takes advantage of the hypixel API java library found here:
    http://github.com/hypixeldev/publicapi/
    and I have something working in my development environment. However, when I build a jar and attempt to load it into my main client, I get NoClassDefFound errors for classes in the jar:

    Code:
    [03:26:02] [Client thread/ERROR] [FML]: Fatal errors were detected during the transition from CONSTRUCTING to PREINITIALIZATION. Loading cannot continue
    [03:26:02] [Client thread/ERROR] [FML]:
        States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
        UC    mcp{9.19} [Minecraft Coder Pack] (minecraft.jar)
        UC    FML{8.0.99.99} [Forge Mod Loader] (forge-1.8.9-11.15.1.1722-universal.jar)
        UC    Forge{11.15.1.1722} [Minecraft Forge] (forge-1.8.9-11.15.1.1722-universal.jar)
        UE    HelloWorldMod{1.0} [HELLOWORLD Mod] (Hello-1.0.jar)
        UC    animations{6.7} [Orange's 1.7 Animations] (Orange's+1.7+Animations-6.7.jar)
        UC    orangesimplemod{1.0} [orangesimplemod] (Orange's+Simple+Mods-1.2.jar)
        UC    ProjectL{0.2} [ProjectL] (ProjectL-0.2.jar)
        UC    keystrokesmod{5.0.1} [KeystrokesMod] (Sk1er KeystrokesMod-5.0.1 (1.8.9).jar)
        UC    enhancements{7.7} [Vanilla Enhancements] (Vanilla+Enhancements-7.7.jar)
    [03:26:02] [Client thread/ERROR] [FML]: The following problems were captured during this phase
    [03:26:02] [Client thread/ERROR] [FML]: Caught exception from HelloWorldMod
    java.lang.NoClassDefFoundError: net/hypixel/api/reply/AbstractReply
        at java.lang.Class.getDeclaredMethods0(Native Method) ~[?:1.8.0_232]
        at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[?:1.8.0_232]
        at java.lang.Class.getDeclaredMethods(Class.java:1975) ~[?:1.8.0_232]
        at net.minecraftforge.fml.common.FMLModContainer.gatherAnnotations(FMLModContainer.java:344) ~[forge-1.8.9-11.15.1.1722-universal.jar:?]
        at net.minecraftforge.fml.common.FMLModContainer.constructMod(FMLModContainer.java:533) ~[forge-1.8.9-11.15.1.1722-universal.jar:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_232]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_232]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_232]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_232]
        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.1722-universal.jar:?]
        at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:189) ~[forge-1.8.9-11.15.1.1722-universal.jar:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_232]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_232]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_232]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_232]
        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.loadMods(Loader.java:512) [Loader.class:?]
        at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:208) [FMLClientHandler.class:?]
        at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:417) [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_232]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_232]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_232]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_232]
        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:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_232]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_232]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_232]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_232]
        at org.multimc.onesix.OneSixLauncher.launchWithMainClass(OneSixLauncher.java:196) [NewLaunch.jar:?]
        at org.multimc.onesix.OneSixLauncher.launch(OneSixLauncher.java:231) [NewLaunch.jar:?]
        at org.multimc.EntryPoint.listen(EntryPoint.java:143) [NewLaunch.jar:?]
        at org.multimc.EntryPoint.main(EntryPoint.java:34) [NewLaunch.jar:?]
    Caused by: java.lang.ClassNotFoundException: net.hypixel.api.reply.AbstractReply
        at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:191) ~[launchwrapper-1.12.jar:?]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:418) ~[?:1.8.0_232]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ~[?:1.8.0_232]
        ... 45 more
    Caused by: java.lang.NullPointerException
        at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:182) ~[launchwrapper-1.12.jar:?]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:418) ~[?:1.8.0_232]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ~[?:1.8.0_232]
        ... 45 more
    [03:26:03] [Client thread/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:func_179870_a:529]: ---- Minecraft Crash Report ----
    
    WARNING: coremods are present:
    Contact their authors BEFORE contacting forge
    
    // Don't be sad, have a hug! <3
    
    Time: 11/2/19 3:26 AM
    Description: There was a severe problem during mod loading that has caused the game to fail
    
    net.minecraftforge.fml.common.LoaderException: java.lang.NoClassDefFoundError: net/hypixel/api/reply/AbstractReply
        at net.minecraftforge.fml.common.LoadController.transition(LoadController.java:162)
        at net.minecraftforge.fml.common.Loader.loadMods(Loader.java:543)
        at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:208)
        at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:417)
        at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:329)
        at net.minecraft.client.main.Main.main(SourceFile:124)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
        at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.multimc.onesix.OneSixLauncher.launchWithMainClass(OneSixLauncher.java:196)
        at org.multimc.onesix.OneSixLauncher.launch(OneSixLauncher.java:231)
        at org.multimc.EntryPoint.listen(EntryPoint.java:143)
        at org.multimc.EntryPoint.main(EntryPoint.java:34)
    Caused by: java.lang.NoClassDefFoundError: net/hypixel/api/reply/AbstractReply
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
        at java.lang.Class.getDeclaredMethods(Class.java:1975)
        at net.minecraftforge.fml.common.FMLModContainer.gatherAnnotations(FMLModContainer.java:344)
        at net.minecraftforge.fml.common.FMLModContainer.constructMod(FMLModContainer.java:533)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
        at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
        at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
        at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
        at com.google.common.eventbus.EventBus.post(EventBus.java:275)
        at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:211)
        at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:189)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
        at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
        at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
        at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
        at com.google.common.eventbus.EventBus.post(EventBus.java:275)
        at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:118)
        at net.minecraftforge.fml.common.Loader.loadMods(Loader.java:512)
        ... 18 more
    Caused by: java.lang.ClassNotFoundException: net.hypixel.api.reply.AbstractReply
        at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:191)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
        ... 45 more
    Caused by: java.lang.NullPointerException
        at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:182)
        ... 47 more
    I understand that this is because the HypixelAPI jar is not bundled into my release jar but I am having trouble figuring out how to 'embed' it properly. Is this the best way to do this? This is my first forge mod so there is a >0 chance I am going about this incorrectly.

    Any help is appreciated
     
    #1
  2. You have to shade the JAR into the mod. The exact process varies with the toolchain you are using.
     
    #2
    • Useful Useful x 1
  3. wiII

    wiII Active Member

    WillOCN
    MVP+
    Bridgers BRIDGE
    Member
    Messages:
    473
    I am using gradle. I got the game to launch but I'm sure this is not the correct way. I cobbled this together from several different sources:

    Code:
    configurations {
        embed
        compile.extendsFrom(embed)
    }
    ...
    dependencies {
        embed 'com.github.HypixelDev:PublicAPI:2.0.0'
    }
    ...
    // Add dependencies to the JAR
    jar {
        from configurations.embed.collect {
            it.isDirectory() ? it : zipTree(it).matching {
                exclude 'META-INF', 'META-INF/**'
            }
        }
    }
    I was reading about the shadow plugin for gradle but since the version bundled with forge 1.8.9 is so old I don't think it would work at all.
     
    #3
  4. The process for shading with ForgeGradle is here: https://forgegradle.readthedocs.io/en/latest/user-guide/shading/
     
    #4
    • Useful Useful x 1
  5. wiII

    wiII Active Member

    WillOCN
    MVP+
    Bridgers BRIDGE
    Member
    Messages:
    473
    #5

Share This Page