Darkhax-Minecraft / Bookshelf

A library mod which adds additional code support beyond what is provided by Forge.
GNU Lesser General Public License v2.1
145 stars 39 forks source link

Bookshelf throws "NoSuchMethodError" while trying to load from ForgeGradle #166

Closed Hauteknits closed 3 years ago

Hauteknits commented 3 years ago

Using forge 1.16.5-36.1.0. Using Bookshelf 10.0.8 loaded via Gradle.

After setting up gradle to load Bookshelf as a dependency, it fails to load with a "NoSuchMethodError." Searching the stacktrace, the method very clearly is defined, however, the stacktrace doesn't use the tags, which makes me thing that something got messed up between using tags and identifiers

Exception message: java.lang.NoSuchMethodError: net.minecraft.util.NonNullList.func_191196_a()Lnet/minecraft/util/NonNullList;
Stacktrace:
    at net.darkhax.bookshelf.registry.CommandRegistry.<init>(CommandRegistry.java:38) ~[bookshelf:10.0.8] {re:classloading}
    at net.darkhax.bookshelf.registry.RegistryHelper.<init>(RegistryHelper.java:50) ~[bookshelf:10.0.8] {re:classloading}
    at net.darkhax.bookshelf.Bookshelf.<init>(Bookshelf.java:87) ~[bookshelf:10.0.8] {re:classloading}
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_271] {}
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_271] {}
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_271] {}
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_271] {}
    at java.lang.Class.newInstance(Class.java:442) ~[?:1.8.0_271] {}
    at net.minecraftforge.fml.javafmlmod.FMLModContainer.constructMod(FMLModContainer.java:81) ~[forge:36.1] {re:classloading}
    at net.minecraftforge.fml.ModContainer.lambda$buildTransitionHandler$4(ModContainer.java:120) ~[forge:?] {re:classloading}
    at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1640) ~[?:1.8.0_271] {}
    at java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1632) ~[?:1.8.0_271] {}
    at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) ~[?:1.8.0_271] {}
    at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1067) ~[?:1.8.0_271] {}
    at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1703) ~[?:1.8.0_271] {}
    at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:172) ~[?:1.8.0_271] {}

I haven't begun to use bookshelf yet, I just wanted to see if the item I made loaded in w/ my custom creative tab

Hauteknits commented 3 years ago

Also adding the line of code in question doesn't seem to throw the same error

Darkhax commented 3 years ago

It looks like the dependency is not being decompiled properly. The method name func_191196_a is a SRG name, but in a development environment the MCP name create is expected. This issue is usually caused by not passing the dependency through ForgeGradle's deobfuscator.

This can be done by simply passing the maven coordinate through the fg.deobf method. This is standard practice but it looks like I forgot to include it in the readme for this repo.

compile fg.deobf("net.darkhax.bookshelf:Bookshelf-1.16.5:${bookshelf_version}")
Hauteknits commented 3 years ago

Awesome, worked as expected. Thanks for the quick response. As I said, I'm a newbie modder and didn't know this trick :)