shedaniel / RoughlyEnoughItems

Clean and Configurable. Your recipe viewer mod for 1.13+.
Other
325 stars 66 forks source link

[Bug] Item Tooltip Fetch should not have Player specified #1659

Open lcy0x1 opened 3 months ago

lcy0x1 commented 3 months ago

What happened?

I found a rare crash when my mod is used with REI in a large modpack, caused by concurrent query of player capability data from my mod while updating player data. I traced back and found the problem here:

https://github.com/shedaniel/RoughlyEnoughItems/blob/ee6aa88ada9e4d1034cb754a8997f8a0996e9cab/runtime/src/main/java/me/shedaniel/rei/plugin/client/entry/ItemEntryDefinition.java#L231C51-L231C76

When building search tree asynchronously, to avoid concurrency issue, the player should not be specified. I understand that sometimes mods could crash without it. Maybe if it throws exception when player is specified, try again with null player?

What mod loaders are you seeing the problem on?

Forge

What do you think this bug is of?

Relevant log output

java.lang.NullPointerException: Cannot invoke "java.util.HashMap.get(Object)" because "this.copy" is null
    at TRANSFORMER/l2library@2.4.27/dev.xkmc.l2library.capability.conditionals.ConditionalData.getData(ConditionalData.java:51)
    at TRANSFORMER/curseofpandora@0.0NONE/dev.xkmc.curseofpandora.event.ClientSpellText.onTooltip(ClientSpellText.java:43)
    at TRANSFORMER/curseofpandora@0.0NONE/dev.xkmc.curseofpandora.event.__ClientSpellText_onTooltip_ItemTooltipEvent.invoke(.dynamic)
    at MC-BOOTSTRAP/net.minecraftforge.eventbus/net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:73)
    at MC-BOOTSTRAP/net.minecraftforge.eventbus/net.minecraftforge.eventbus.EventBus.post(EventBus.java:315)
    at MC-BOOTSTRAP/net.minecraftforge.eventbus/net.minecraftforge.eventbus.EventBus.post(EventBus.java:296)
    at TRANSFORMER/forge@47.2.32/net.minecraftforge.event.ForgeEventFactory.onItemTooltip(ForgeEventFactory.java:360)
    at TRANSFORMER/minecraft@1.20.1/net.minecraft.world.item.ItemStack.m_41651_(ItemStack.java:763)
    at TRANSFORMER/roughlyenoughitems@12.1.725/me.shedaniel.rei.plugin.client.entry.ItemEntryDefinition.tryGetItemStackToolTip(ItemEntryDefinition.java:231)
    at TRANSFORMER/roughlyenoughitems@12.1.725/me.shedaniel.rei.plugin.client.entry.ItemEntryDefinition$ItemEntryRenderer.getTooltip(ItemEntryDefinition.java:369)
    at TRANSFORMER/roughlyenoughitems@12.1.725/me.shedaniel.rei.impl.common.entry.AbstractEntryStack.getTooltip(AbstractEntryStack.java:195)
    at TRANSFORMER/roughlyenoughitems@12.1.725/me.shedaniel.rei.impl.client.search.argument.type.TooltipArgumentType.tryGetEntryStackTooltip(TooltipArgumentType.java:90)
    at TRANSFORMER/roughlyenoughitems@12.1.725/me.shedaniel.rei.impl.client.search.argument.type.TooltipArgumentType.cacheData(TooltipArgumentType.java:75)
    at TRANSFORMER/roughlyenoughitems@12.1.725/me.shedaniel.rei.impl.client.search.argument.type.TooltipArgumentType.cacheData(TooltipArgumentType.java:45)
    at TRANSFORMER/roughlyenoughitems@12.1.725/me.shedaniel.rei.impl.client.search.argument.ArgumentCache.cacheStacks(ArgumentCache.java:138)
    at TRANSFORMER/roughlyenoughitems@12.1.725/me.shedaniel.rei.impl.client.search.argument.ArgumentCache.lambda$cache$1(ArgumentCache.java:110)
    at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768)
    at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1760)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
    at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312)
    at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843)
    at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808)
    at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188)

Anything else?

No response

By submitting this issue, I have included the necessary logs by pasting the contents into the correct location or attaching the file as an upload.

By submitting this issue, I have confirmed my REI and REI's dependencies are up to date.