Transformer loading Minecraft classes
squeek502 opened this issue ยท 3 comments
Figured I'd cross-post this from squeek502/AppleCore#129 (comment)
This is an issue worth fixing (I know from experience, see squeek502/AppleCore#19)
My best guess is that your coremod/transformer classes are (unintentionally) loading classes that they shouldn't be. Any class that is imported during transformer loading could fail to be transformed by any transformers that have not been registered in the load order.
I put in a debug print that potentially shows the issue. This is the log after SortingIndex is changed to 2000 in RandomPatches:
[23:30:50] [main/DEBUG] [FML]: Injecting coremod AppleCore \{squeek.applecore.AppleCore\} class transformers
[23:30:50] [main/TRACE] [FML]: Registering transformer squeek.applecore.asm.TransformerModuleHandler
[23:30:50] [main/DEBUG] [FML]: Injection complete
[23:30:50] [main/DEBUG] [FML]: Running coremod plugin for AppleCore \{squeek.applecore.AppleCore\}
...
[23:30:50] [main/DEBUG] [FML]: Injecting coremod RandomPatches \{com.therandomlabs.randompatches.core.RPCore\} class transformers
[23:30:50] [main/TRACE] [FML]: Registering transformer com.therandomlabs.randompatches.core.RPTransformer
[23:30:50] [main/INFO] [STDOUT]: [squeek.applecore.asm.module.ModuleFoodStats:transform:30]: [applecore] Modifying EntityPlayer
[23:30:50] [main/DEBUG] [FML]: Injection complete
[23:30:50] [main/DEBUG] [FML]: Running coremod plugin for RandomPatches \{com.therandomlabs.randompatches.core.RPCore\}
As you can imagine, if the load orders were reversed, then the EntityPlayer
class would be sent to transformers before AppleCore's transformer was registered, meaning AppleCore would never have a chance to modify it.
Best practice for core mods is to keep them as insular as possible--never import any Minecraft classes or any classes that might import Minecraft classes. Your RPTransformer
class imports com.therandomlabs.randompatches.RandomPatches
, which in turn imports net.minecraftforge.client.ClientCommandHandler
/net.minecraftforge.common.MinecraftForge
, which I'm assuming is causing this issue.
Changing the sort order will fix it for now, but any coremod with a SortingIndex above yours can have similar conflicts.
I know this is old, but i would like to add that recently in 1.12.2 the mod Oversaturation was the cause of my eating and crashing.
I'll separate the constants I need out of RandomPatches
, but I'll also try and find out what's causing EntityPlayer
to load early.
With sorting index back at 1002 and AppleCore 3.1.4:
[main/DEBUG] [randompatches]: Patching class: net.minecraft.client.Minecraft
[main/DEBUG] [randompatches]: Patching method: func_175609_am
[main/DEBUG] [randompatches]: Patching method: func_152348_aa
[main/INFO] [STDOUT]: [squeek.applecore.asm.module.ModuleFoodStats:transform:30]: Modifying EntityPlayer
[main/DEBUG] [randompatches]: Patching class: net.minecraft.client.gui.GuiIngameMenu
[main/DEBUG] [randompatches]: Patching method: func_146284_a
Also tried eating bread, and it went fine.