Custom item names shift the insulation tooltip
SiverDX opened this issue ยท 4 comments
See
empty[style={color=white}, siblings=[translation{key='misc.apotheosis.affix_name.three', args=[translation{key='affix.irons_spellbooks:armor/attribute/mana', args=[]}[style={}], translation{key='item.minecraft.leather_helmet', args=[]}, translation{key='affix.apotheosis:armor/attribute/stalwart.suffix', args=[]}[style={}]]}[style={color=#ED7014}]]]
Might only occur with https://www.curseforge.com/minecraft/mc-mods/apotheosis since anvil renames stores the name in a tag
Figured it out, this only happens in 1.19. I was testing in 1.20. I believe this is happening because I was using ItemStack#getDisplayName()
to find the line where the item's name is, when I should have been using ItemStack#getHoverName()
.
It seems like the first one just gets the item's name from NBT (which would work for anvil-named items, as you mentioned, but not names set by other means), and the second one actually returns the item's name as it is displayed.
I also figured out that directly comparing Components isn't the way to go, since they don't have a custom equals() method and it just compares the hash, which can be fickle. I decided to compare the string representation of the lines and had better results.