squeek502 / AppleCore

An API for modifying the food and hunger mechanics of Minecraft
The Unlicense
55 stars 24 forks source link

Crash on world load; conflict with RandomPatches 1.5.0.1 #129

Closed Zarepheth closed 6 years ago

Zarepheth commented 6 years ago

Game loads, but upon choosing the world, the game soon crashes. It looks like a field which AppleCore adds at run-time is no longer being populated.

The primary stack trace for the crashing exception only implicates AppleCore. Although additional stack traces in the full log, which seem to occur as Minecraft shuts down, may indicate issues with other mods.

AppleCore has not updated recently, so I'm guessing a change in the Forge api may be the cause. I'll try reverting some of my recent updates - that might pinpoint the source of the conflict.

Versions:

Minecraft Version: 1.12.2
Operating System: Windows 10 (amd64) version 10.0
Java Version: 1.8.0_181, Oracle Corporation
forge-1.12.2-14.23.4.2757-universal.jar
AppleCore (AppleCore-mc1.12.2-3.1.3.jar)
RandomPatches (randompatches-1.12.2-1.5.0.1.jar)
LoadingPlugin (Quark-r1.5-127.jar)

Full log on paste.ee;

Description: Ticking memory connection

java.lang.RuntimeException: FoodStats has a null player field (this field is added by AppleCore at runtime) on player '<unknown>' (class = net.minecraft.util.FoodStats). This likely means that some mod has overloaded FoodStats, which is incompatible with AppleCore.
    at squeek.applecore.asm.Hooks.verifyFoodStats(Hooks.java:47)
    at squeek.applecore.asm.Hooks.getMaxHunger(Hooks.java:270)
    at net.minecraft.util.FoodStats.<init>(SourceFile:21)
    at net.minecraft.entity.player.EntityPlayer.<init>(EntityPlayer.java:115)
    at net.minecraft.entity.player.EntityPlayerMP.<init>(EntityPlayerMP.java:158)
    at net.minecraft.server.management.PlayerList.func_148545_a(PlayerList.java:504)
    at net.minecraft.server.network.NetHandlerLoginServer.func_147326_c(NetHandlerLoginServer.java:135)
    at net.minecraft.server.network.NetHandlerLoginServer.func_73660_a(NetHandlerLoginServer.java:63)
    at net.minecraft.network.NetworkManager.func_74428_b(NetworkManager.java:285)
    at net.minecraft.network.NetworkSystem.func_151269_c(NetworkSystem.java:180)
    at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:790)
    at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:668)
    at net.minecraft.server.integrated.IntegratedServer.func_71217_p(IntegratedServer.java:252)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:526)
    at java.lang.Thread.run(Unknown Source)
squeek502 commented 6 years ago

Unlikely that it's Forge, most likely it's a conflict with a mod you recently installed/updated.

Zarepheth commented 6 years ago

Same problem on forge-1.12.2-14.23.4.2756-universal.jar However, reverting RandomPatches seems to fix the problem.

Erring version of RandomPatches: randompatches-1.12.2-1.5.0.1.jar Working version: randompatches-1.12.2-1.4.1.1.jar

squeek502 commented 6 years ago

After briefly looking through Random Patches' source code, it's unclear how it could be causing this. However, this crash is related to #128 which I've been meaning to fix and that might clear this up as well.

squeek502 commented 6 years ago

Might be fixed in v3.1.4: https://github.com/squeek502/AppleCore/releases/tag/v3.1.4

Give it a try and let me know.

(will also be on Curseforge once it's approved)

Zarepheth commented 6 years ago

I downloaded the Apple Core v 3.1.4 jar from Github and installed it. Returned RandomPatches to the most recent version (v 1.5.0.1). And now my world successfully loads!

Thank you!

Zarepheth commented 6 years ago

I think I spoke too soon. True, I can now load my world. But after playing for about 30 minutes, the game crashed as I attempted to eat some bread! (minecraft:bread)

Full Log on Paste.ee.

java.lang.RuntimeException: FoodStats has a null player field (this field is added by AppleCore at runtime) on player '<unknown>' (class = net.minecraft.util.FoodStats). This likely means that some mod has overloaded FoodStats, which is incompatible with AppleCore.
    at squeek.applecore.asm.Hooks.verifyFoodStats(Hooks.java:53)
    at squeek.applecore.asm.Hooks.needFood(Hooks.java:270)
    at net.minecraft.util.FoodStats.func_75121_c(SourceFile)
    at net.minecraft.entity.player.EntityPlayer.func_71043_e(EntityPlayer.java:2072)
    at net.minecraft.item.ItemFood.func_77659_a(SourceFile:78)
    at net.minecraft.item.ItemStack.func_77957_a(ItemStack.java:217)
    at net.minecraft.client.multiplayer.PlayerControllerMP.func_187101_a(PlayerControllerMP.java:511)
    at net.optifine.override.PlayerControllerOF.func_187101_a(PlayerControllerOF.java:80)
    at net.minecraft.client.Minecraft.func_147121_ag(Minecraft.java:1596)
    at net.minecraft.client.Minecraft.func_184117_aA(Minecraft.java:2253)
    at net.minecraft.client.Minecraft.func_184118_az(Minecraft.java:2019)
    at net.minecraft.client.Minecraft.func_71407_l(Minecraft.java:1807)
    at net.minecraft.client.Minecraft.func_71411_J(Minecraft.java:1097)
    at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:397)
    at net.minecraft.client.main.Main.main(SourceFile:123)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    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(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    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)
squeek502 commented 6 years ago

Can confirm that I can reproduce this crash, but I'm really confused as to what could be causing it. I can't find anything in the RandomPatches source code that would conflict...

TheRandomLabs commented 6 years ago

This is pretty strange. I'll have a look at this now.

squeek502 commented 6 years ago

@TheRandomLabs AppleCore adds a constructor with a player field to FoodStats, and modifies the EntityPlayer.foodStats initialization to use that new constructor. Usually, that means that all EntityPlayer.foodStats have a valid player field, as they use the modified initialization. Somehow that is not happening, though.

Usually this is caused by a mod overriding FoodStats and then setting the player's foodStats field manually to their version, but that's not what's happening either. Somehow it seems like your mod is indirectly interfering in that initialization process or something, but the classes you modify are not even obviously related to anything EntityPlayer/FoodStats related.

TheRandomLabs commented 6 years ago

I couldn't figure out what was affecting FoodStats, but I tried setting @IFMLLoadingPlugin.SortingIndex(2000) (higher than AppleCore's). I tried eating bread, and it didn't crash. See if 1.12.2-1.5.0.2 works when it's accepted.

squeek502 commented 6 years ago

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.

EDIT: Here's the issue from when AppleCore was causing the same problems: https://github.com/squeek502/AppleCore/issues/19

Zarepheth commented 6 years ago

Talk about an esoteric problem! I'm surprised you guys figured it out so fast.

K4N0 commented 5 years ago

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.

squeek502 commented 5 years ago

@K4N0 it's a known incompatibility: https://github.com/squeek502/AppleCore/issues/124