[CRASH] getDurabilityForDisplay assumes player is never null
Wabbit0101 opened this issue ยท 0 comments
At clientside startup it's possible for Forge to trigger ForgeEventFactory.onItemTooltip with NULL for the player (as indicated w/the @nullable annotation). If this occurs, this crash can happen (a specific stack is clipped below):
at net.blay09.mods.waystones.PlayerWaystoneHelper.getWaystonesTag(PlayerWaystoneHelper.java:19)
at net.blay09.mods.waystones.PlayerWaystoneHelper.getLastWarpStoneUse(PlayerWaystoneHelper.java:63)
at net.blay09.mods.waystones.item.ItemWarpStone.getDurabilityForDisplay(ItemWarpStone.java:99)
at net.blay09.mods.waystones.item.ItemWarpStone.showDurabilityBar(ItemWarpStone.java:93)
at org.jwaresoftware.mcmods.smarthoppers.runtime.TooltipEnricher.onItemTooltip(TooltipEnricher.java:87)
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_678_TooltipEnricher_onItemTooltip_ItemTooltipEvent.invoke(.dynamic)
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182)
at net.minecraftforge.event.ForgeEventFactory.onItemTooltip(ForgeEventFactory.java:325)
at net.minecraft.item.ItemStack.func_82840_a(ItemStack.java:889)
at net.minecraft.client.Minecraft.lambda$populateSearchTreeManager$1(Minecraft.java:575)
at net.minecraft.client.util.SearchTree.func_194042_b(SourceFile:49)
at net.minecraft.client.util.SearchTree.func_194043_a(SourceFile:44)
The original call is populating the client-side search index on startup. The TooltipEnricher mod calls getDurability with the ItemStack it's provided (no EntityPlayer from here...but ItemWarpStone is mapping into Minecraft.player which is null). Also appparently the Item durability methods are not only client-side methods (although I also thought they were...doesn't help in this case anyways as it's from client side the crash is triggered)
Version details:
| UCH | waystones | 4.0.43 | Waystones_1.12.2-4.0.43.jar
forge-1.12.2-14.23.4.2705-universal.jar