emilyploszaj / emi

A featureful and accessible item and recipe viewer
MIT License
220 stars 45 forks source link

ToolTip Context Not Passing Context #575

Closed fzzyhmstrs closed 4 days ago

fzzyhmstrs commented 2 weeks ago

Checking on the log below from Technici4n, it looks like ItemEmiStack (and maybe elsewhere? Didn't check) uses TooltipContext.DEFAULT in it's tooltip method. This short circuits any possibility of context in the context.

TooltipContext.create(client.world), which takes a nullable param, would build contextual Contexts as needed by users.

https://github.com/emilyploszaj/emi/blob/615d816a81de7627292934c1c3d99b4b6931cfd1/xplat/src/main/java/dev/emi/emi/api/stack/ItemEmiStack.java#L162

java.lang.NullPointerException: Cannot invoke "net.minecraft.core.HolderLookup$Provider.lookupOrThrow(net.minecraft.resources.ResourceKey)" because the return value of "net.minecraft.world.item.Item$TooltipContext.registries()" is null
    at TRANSFORMER/modern_industrialization@0.0.0-local/aztech.modern_industrialization.items.diesel_tools.DieselToolItem.appendHoverText(DieselToolItem.java:134)
    at TRANSFORMER/minecraft@1.21/net.minecraft.world.item.ItemStack.getTooltipLines(ItemStack.java:772)
    at TRANSFORMER/emi@1.1.7+1.21+neoforge/dev.emi.emi.api.stack.ItemEmiStack.getTooltipText(ItemEmiStack.java:162)
    at TRANSFORMER/emi@1.1.7+1.21+neoforge/dev.emi.emi.search.EmiSearch.bake(EmiSearch.java:62)
    at TRANSFORMER/emi@1.1.7+1.21+neoforge/dev.emi.emi.runtime.EmiReloadManager$ReloadWorker.run(EmiReloadManager.java:222)
    at java.base/java.lang.Thread.run(Thread.java:1583)
emilyploszaj commented 4 days ago

This was changed to provide context if possible in 1.1.8