Bernasss12 / BetterEnchantedBooks

Makes it easier to identify different enchantment books.
MIT License
12 stars 9 forks source link

Fix possible NullPointerException trying to draw tooltip icons #34

Closed Fourmisain closed 3 years ago

Fourmisain commented 3 years ago

When using Show Off with an enchanted book, holding shift to show the tooltip icons (or having them set to always draw) will crash the game on mouse-over.

This comes back to the general issue of enchantedItemStack not always being set and cachedTooltipIcons will return null, thus producing a NPE. Since this general issue is hard to fix, I retorted to the simple fix of skipping the whole method.

I should also say that since cachedTooltipIcons is a WeakHashMap, get can always return null, so this might fix some crashes in low memory situations as well.