squeek502 / AppleCore

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

Crash in 1.11.2 with Animania and AppleCore #97

Closed capnkirok closed 7 years ago

capnkirok commented 7 years ago

This crash has haunted me for some time now. The food "Truffle Soup" works as intended with any other mod installed, but crashes with AppleCore, and users refer back to me.

---- Minecraft Crash Report ----

WARNING: coremods are present: AppleCore (AppleCore-mc1.11.2-2.2.2.jar) Contact their authors BEFORE contacting forge

// Don't be sad. I'll do better next time, I promise!

Time: 7/30/17 11:55 AM Description: Ticking player

java.lang.NullPointerException: Ticking player at net.minecraft.util.FoodStats.func_151686_a(SourceFile:32) at com.animania.common.items.ItemTruffleSoup.func_77654_b(ItemTruffleSoup.java:69) at net.minecraft.item.ItemStack.func_77950_b(ItemStack.java:201) at net.minecraft.entity.EntityLivingBase.func_71036_o(EntityLivingBase.java:2691) at net.minecraft.entity.player.EntityPlayerMP.func_71036_o(EntityPlayerMP.java:1030) at net.minecraft.entity.EntityLivingBase.func_184608_ct(EntityLivingBase.java:2591) at net.minecraft.entity.EntityLivingBase.func_70071h(EntityLivingBase.java:2007) at net.minecraft.entity.player.EntityPlayer.func_70071h(EntityPlayer.java:232) at net.minecraft.entity.player.EntityPlayerMP.func_71127_g(EntityPlayerMP.java:329) at net.minecraft.network.NetHandlerPlayServer.func_73660_a(NetHandlerPlayServer.java:164) at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher$1.func_73660_a(NetworkDispatcher.java:215) at net.minecraft.network.NetworkManager.func_74428_b(NetworkManager.java:287) at net.minecraft.network.NetworkSystem.func_151269_c(NetworkSystem.java:180) at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:743) at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:624) at net.minecraft.server.integrated.IntegratedServer.func_71217_p(IntegratedServer.java:149) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:482) at java.lang.Thread.run(Thread.java:745)

A detailed walkthrough of the error, its code path and all known details is as follows:

-- Head -- Thread: Server thread Stacktrace: at net.minecraft.util.FoodStats.func_151686_a(SourceFile:32) at com.animania.common.items.ItemTruffleSoup.func_77654_b(ItemTruffleSoup.java:69) at net.minecraft.item.ItemStack.func_77950_b(ItemStack.java:201) at net.minecraft.entity.EntityLivingBase.func_71036_o(EntityLivingBase.java:2691) at net.minecraft.entity.player.EntityPlayerMP.func_71036_o(EntityPlayerMP.java:1030) at net.minecraft.entity.EntityLivingBase.func_184608_ct(EntityLivingBase.java:2591) at net.minecraft.entity.EntityLivingBase.func_70071h(EntityLivingBase.java:2007) at net.minecraft.entity.player.EntityPlayer.func_70071h(EntityPlayer.java:232)

-- Player being ticked -- Details: Entity Type: null (net.minecraft.entity.player.EntityPlayerMP) Entity ID: 1672 Entity Name: Purplicious_Cow Entity's Exact location: 7.50, 67.00, 118.50 Entity's Block location: World: (7,67,118), Chunk: (at 7,4,6 in 0,7; contains blocks 0,0,112 to 15,255,127), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511) Entity's Momentum: 0.00, -0.08, 0.00 Entity's Passengers: [] Entity's Vehicle: ERROR NullPointerException: null Stacktrace: at net.minecraft.entity.player.EntityPlayerMP.func_71127_g(EntityPlayerMP.java:329) at net.minecraft.network.NetHandlerPlayServer.func_73660_a(NetHandlerPlayServer.java:164) at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher$1.func_73660_a(NetworkDispatcher.java:215) at net.minecraft.network.NetworkManager.func_74428_b(NetworkManager.java:287)

-- Ticking connection -- Details: Connection: net.minecraft.network.NetworkManager@539cb82e Stacktrace: at net.minecraft.network.NetworkSystem.func_151269_c(NetworkSystem.java:180) at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:743) at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:624) at net.minecraft.server.integrated.IntegratedServer.func_71217_p(IntegratedServer.java:149) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:482) at java.lang.Thread.run(Thread.java:745)

-- System Details -- Details: Minecraft Version: 1.11.2 Operating System: Mac OS X (x86_64) version 10.11.6 Java Version: 1.8.0_74, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 300355552 bytes (286 MB) / 590761984 bytes (563 MB) up to 2134114304 bytes (2035 MB) JVM Flags: 5 total; -Xmx2G -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:-UseAdaptiveSizePolicy -Xmn128M IntCache: cache: 0, tcache: 0, allocated: 13, tallocated: 95 FML: MCP 9.38 Powered by Forge 13.20.1.2414 8 mods loaded, 8 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored UCHIJAAAA minecraft{1.11.2} [Minecraft] (minecraft.jar) UCHIJAAAA mcp{9.19} [Minecraft Coder Pack] (minecraft.jar) UCHIJAAAA FML{8.0.99.99} [Forge Mod Loader] (forge-1.11.2-13.20.1.2414.jar) UCHIJAAAA forge{13.20.1.2414} [Minecraft Forge] (forge-1.11.2-13.20.1.2414.jar) UCHIJAAAA mercurius_updater{1.0} [mercurius_updater] (MercuriusUpdater-1.11.2.jar) UCHIJAAAA craftstudioapi{0.3.0-beta} [CraftStudio API] (CraftStudioAPI-universal-0.3.0.86-mc1.11.2-beta.jar) UCHIJAAAA animania{1.2.2} [Animania] (animania-1.11.2-1.2.2.jar) UCHIJAAAA applecore{2.2.2} [AppleCore] (AppleCore-mc1.11.2-2.2.2.jar) Loaded coremods (and transformers): AppleCore (AppleCore-mc1.11.2-2.2.2.jar) squeek.applecore.asm.TransformerModuleHandler GL info: ERROR RuntimeException: No OpenGL context found in the current thread. Profiler Position: N/A (disabled) Player Count: 1 / 8; [EntityPlayerMP['Purplicious_Cow'/1672, l='New World', x=7.50, y=67.00, z=118.50]] Type: Integrated Server (map_client.txt) Is Modded: Definitely; Client brand changed to 'fml,forge'

capnkirok commented 7 years ago

Here's the Item file. The big difference between this food and the others in my mod are that this one uses OnItemUseFinish instead of OnFoodEaten.

https://gist.github.com/capnkirok/dbdbf524d0136b68c62596e3a3a976b4

squeek502 commented 7 years ago

From what I can tell, the crash is happening because you are modifying the stack size to 0 before calling entityplayer.getFoodStats().addStats(this, stack);, which means that the ItemStack is being marked as empty and is therefore returning ItemAir from stack.getItem() when AppleCore queries it to get its hunger values. AppleCore then crashes, since it can't get food values for ItemAir.

So, the fix would be to swap the ordering of your shrink call, and only do it after calling addStats, onFoodEaten, etc. (see the default ItemFood.onItemUseFinish for a reference).

Not sure if there's anything I should do on AppleCore's end. I guess I could make the error message more informative?

capnkirok commented 7 years ago

Thanks. I'll give it a whirl and report back.

capnkirok commented 7 years ago

Yep, that worked! You could pop a message, might be useful since the error now comes from MC, and it doesn't mention AppleCore, so seems invalid.