The issue I'm experiencing there is that when I attempt to cast most TextComponents to a TranslatableComponent, the game crashes saying it cannot. I fixed this by running an instanceof check, but that is only returning a few translation keys, none of which are what I need. Most look like this:
item.modifiers.chest
attribute.modifier.plus.0
attribute.modifier.plus.0
item.modifiers.mainhand
attribute.modifier.plus.0
attribute.modifier.take.0
When I tested using regular components, I saw names of every single item which verified that was working, however in this instance I am only seeing the strings listed above and no item ids, block ids, or "attribute.name.generic.armor" as I need.
I feel I may be doing something completely wrong. I'll post an excerpt of my code below from inside my ItemTooltipEvent listener (apologies for the messy variable names during testing)
List<Component> tooltip = event.getToolTip();
int size = tooltip.size();
int i = 0;
while (i < size) {
Component ttcomp = tooltip.get(i);
if (ttcomp instanceof TranslatableComponent) {
TranslatableComponent trancomp = (TranslatableComponent) ttcomp;
String ttkey = trancomp.getKey();
if (ttkey.contains("attribute.name.generic.armor")) {
event.getToolTip().remove(i);
size -= 1;
i -= 1;
}
}
i += 1;
}
Just to outline, the purpose of the code is to search / iterate incoming tooltips for the "attribute.name.generic.armor" key and then remove those lines from the tooltip.