Closed Fourmisain closed 2 years ago
I honestly don't remember why the LiteralText.EMPTY, but I think in some cases there could be a linebreak then stuff that should not be removed...
And the reason for not using a Redirect is mod compatibility, multiple mods cannot redirect the same invoke.
I honestly don't remember why the LiteralText.EMPTY, but I think in some cases there could be a linebreak then stuff that should not be removed...
Alright, kept the logic in, just in case!
I rewrote it again, it's slightly less readable but O(n) and about 30% faster in common cases - not that it really matters much.
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
)https://github.com/Queerbric/Inspecio/blob/bdeaa062c48e8170c2450c16d431103c3fb2c2de/src/main/java/io/github/queerbric/inspecio/mixin/PotionItemMixin.java#L57-L65
If e.g.
tooltip.size()
is 3 andoldTooltipLength
is 2, it'll enter the loop, remove the tooltip at index 2 and continue the loop sincetooltip.size() > 1
, it'll callget
at the same index which fails since index 2 is now out of bounds. Fix is to simply change the 1 tooldTooltipLength
.I rewrote the offending code but didn't quite finish it because I have a question: Why does this removal loop
break
if aLiteralText.EMPTY
is 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. redirectPotionUtil.buildTooltip()
to do nothing.