Fix OutOfBoundsException in Potion/TippedArrowItemMixin #38
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I ran into this while messing around with tooltips, adding a second/sub name to items.
Looking at
PotionItemMixin(which is basically the exact same asTippedArrowItemMixin)Inspecio/src/main/java/io/github/queerbric/inspecio/mixin/PotionItemMixin.java
Lines 57 to 65 in bdeaa06
If e.g.
tooltip.size()is 3 andoldTooltipLengthis 2, it'll enter the loop, remove the tooltip at index 2 and continue the loop sincetooltip.size() > 1, it'll callgetat the same index which fails since index 2 is now out of bounds.Fix is to simply change the 1 to
oldTooltipLength.I rewrote the offending code but didn't quite finish it because I have a question:
Why does this removal loop
breakif aLiteralText.EMPTYis found?Is this something for mod compat? Because this doesn't seem to happen in Vanilla at all and it seems much easier to e.g. redirect
PotionUtil.buildTooltip()to do nothing.