Spice of Life: Carrot Edition

Spice of Life: Carrot Edition

57M Downloads

Failed to save player data

tyra314 opened this issue ยท 1 comments

commented

Hi,

I encountered a pretty nifty bug in your mod. (At least, this is what I think happened)
I'm playing a custom mod pack and recently removed DuckCraft from the pack.
But I had already eaten food items from this mod.
Now, I get an NPE during any attempts to save player data.

[14:19:37] [Server thread/FATAL]: Error executing task
java.util.concurrent.ExecutionException: java.lang.NullPointerException
        at java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[?:1.8.0_152]
        at java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[?:1.8.0_152]
        at net.minecraft.util.Util.func_181617_a(SourceFile:47) [h.class:?]
        at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:721) [MinecraftServer.class:?]
        at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:396) [nz.class:?]
        at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:666) [MinecraftServer.class:?]
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:524) [MinecraftServer.class:?]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_152]
Caused by: java.lang.NullPointerException
        at com.cazsius.solcarrot.capability.FoodCapability.serializeNBT(FoodCapability.java:47) ~[FoodCapability.class:?]
        at com.cazsius.solcarrot.capability.DeathHandler.onClone(DeathHandler.java:15) ~[DeathHandler.class:?]
        at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_328_DeathHandler_onClone_Clone.invoke(.dynamic) ~[?:?]
        at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) ~[ASMEventHandler.class:?]
        at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:179) ~[EventBus.class:?]
        at net.minecraftforge.event.ForgeEventFactory.onPlayerClone(ForgeEventFactory.java:535) ~[ForgeEventFactory.class:?]
        at net.minecraft.entity.player.EntityPlayerMP.func_193104_a(EntityPlayerMP.java:1176) ~[oq.class:?]
        at net.minecraft.server.management.PlayerList.func_72368_a(PlayerList.java:540) ~[pl.class:?]
        at net.minecraft.network.NetHandlerPlayServer.func_147342_a(NetHandlerPlayServer.java:1117) ~[pa.class:?]
        at net.minecraft.network.play.client.CPacketClientStatus.func_148833_a(SourceFile:31) ~[lb.class:?]
        at net.minecraft.network.play.client.CPacketClientStatus.func_148833_a(SourceFile:8) ~[lb.class:?]
        at net.minecraft.network.PacketThreadUtil$1.run(SourceFile:13) ~[hv$1.class:?]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_152]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_152]
        at net.minecraft.util.Util.func_181617_a(SourceFile:46) ~[h.class:?]
        ... 5 more

From looking at these lines of code:
https://github.com/Cazsius/Spice-of-Life-Carrot-Edition/blob/master-1.11.2/src/main/java/com/cazsius/solcarrot/capability/FoodCapability.java#L50

I guess, the player attached NBT still contains the old, but now non-existent food items I ate.
So it seems like this line will cause the NPE.

I'm sorry, this is pretty vague, but the exceptions get caught somewhere, so there's no crash report. :(

*edit: when trying to clear the foodlist, there's also an NPE:

[14:45:12] [Server thread/WARN]: Couldn't process command: clearfoodlist tyra_oa
java.lang.NullPointerException: null
        at com.cazsius.solcarrot.command.CommandClearFoodArray.func_184881_a(CommandClearFoodArray.java:37) ~[CommandClearFoodArray.class:?]
        at net.minecraft.command.CommandHandler.func_175786_a(CommandHandler.java:119) [bj.class:?]
        at net.minecraft.command.CommandHandler.func_71556_a(CommandHandler.java:91) [bj.class:?]
        at net.minecraft.server.dedicated.DedicatedServer.func_71333_ah(DedicatedServer.java:432) [nz.class:?]
        at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:397) [nz.class:?]
        at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:666) [MinecraftServer.class:?]
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:524) [MinecraftServer.class:?]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_152]
commented

Issue should be fixed with the latest commit, will push when ready.