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

IllegalAccessError in dev environment (Roman numerals) #114

Closed ejektaflex closed 5 years ago

ejektaflex commented 5 years ago

I'm trying to work with GameStages, and have it (as well as Bookshelf) added to my build.gradle. However, either during or after PostInit Bookshelf seems to crash with an IllegalAccessError. This seems like a copy of #109, although the given solution is not valid (cannot set useDepAts = true since useDepAts is private, and setUseDepAts(true) does not change the outcome, giving the same crash.)

Edit: I did try and change mappings to "stable_39", thinking that maybe an access transformer had changed access to a variable or some such, but to no avail.

Bookshelf: 2.3.552 GameStages: 2.0.114 Forge: 1.12.2-14.23.5.2796

Here is the crash:

net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from Bookshelf (bookshelf)
Caused by: java.lang.IllegalAccessError: tried to access field net.minecraft.client.resources.I18n.i18nLocale from class net.darkhax.bookshelf.client.RomanNumerals
    at net.darkhax.bookshelf.client.RomanNumerals.mapLevels(RomanNumerals.java:50)
    at net.darkhax.bookshelf.client.RomanNumerals.insertRomanNumerals(RomanNumerals.java:43)
    at net.darkhax.bookshelf.Bookshelf.onLoadComplete(Bookshelf.java:133)
    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.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:626)
    at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91)
    at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)
    at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)
    at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
    at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)
    at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)
    at com.google.common.eventbus.EventBus.post(EventBus.java:217)
    at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:219)
    at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:197)
    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.Subscriber.invokeSubscriberMethod(Subscriber.java:91)
    at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)
    at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)
    at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
    at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)
    at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)
    at com.google.common.eventbus.EventBus.post(EventBus.java:217)
    at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:136)
    at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:752)
    at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:336)
    at net.minecraft.client.Minecraft.init(Minecraft.java:582)
    at net.minecraft.client.Minecraft.run(Minecraft.java:422)
    at net.minecraft.client.main.Main.main(Main.java:118)
    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 net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
    at GradleStart.main(GradleStart.java:25)
ejektaflex commented 5 years ago

The only valid solution at the moment is to set Bookshelf & GameStages to compileOnly in build.gradle, and then put the game-ready versions in the mods folder for runtime. It seems that useDepAts cannot be used for me (It is apparently private?), though setUseDepAts(true) can be used (although, as mentioned, it still causes the IllegalArgumentException). Do you know what would be causing this?

Darkhax commented 5 years ago

Access transformers are not being loaded properly in your environment. You need to make sure the dependencies are being loaded in a way that ForgeGradle can detect. Here is a working example.

ejektaflex commented 5 years ago

Yes, that does not work. I'm using the deobf jars for compilation in the way that you've shown, yet your access transformers arent being loaded properly.

(What you've shown is the very first thing I tried, I'm of course going to try replicate your build.gradle from another setup before reporting an issue on it)

Is there any issue with using the compiled files for runtime and deobf for compilation, as I'm doing now? It seems to be the best solution, though it's obviously not perfect.

Darkhax commented 5 years ago

I am not sure. Perhaps this is an issue with gradle version. I use version 4.3+ for all of my wrappers.

ejektaflex commented 5 years ago

I'm using 4.10.3, but that could very well be it. I think that I'll stick with this method for now, perhaps try out v5.0+. Regardless, it works.