Mekanism

Mekanism

111M Downloads

IMekanismAccess.jeiHelper() can't be used within JeiPlugins

ramidzkh opened this issue ยท 2 comments

commented

Issue description

IMekanismAccess.INSTANCE.jeiHelper() will always throw a new IllegalStateException("JEI is not loaded.") by the time JEI plugins are constructed. This is incompatible with Applied Mekanistics

Steps to reproduce

Invoke IMekanismAccess.INSTANCE.jeiHelper() in the JEI plugin's constructor

Minecraft version

1.20.1 (Latest)

(Neo)Forge version

47.1.79 NeoForge

Mekanism version

10.4.0 (Latest)

Other relevant versions

Applied Mekanistics 1.4.0 equivalent
AE2 15.0.11
JEI 15.2.0.27

If a (crash)log is relevant for this issue, link it here: (It's almost always relevant)

No response

commented

@pupnewfster Any news on this one yet? It's currently a major inconvenience for people using Applied Mekanistics that they're unable to filter AE2 slots to chemicals without using cheated-in creative tanks because of this.

commented

Sorry, forgot to look at it as I was rather busy with things happening in life. Looking at the crash one weird thing is that it seems this is all happening in the constructor at which point the order things are initialized is not that determinate and things may not even be fully loaded/marked as loaded? Is there a reason that you aren't using IModPlugin#onRuntimeAvailable? As currently doing it in the constructor means it gets constructed by JEI during its constructor which given we declare an after JEI means mekanism isn't even constructed yet at the time you are querying it.

If there is some reason why this has to be so early I can switch it back to doing a direct check against the modlist using JEI's modid, but there still is a decent chance that the codepath won't be super stable and may result in undefined behavior at times. Strictly speaking part of me feels like JEI shouldn't be constructing the plugins in its constructor in the first place and should be doing so in one of the setup events... but that is another matter.