Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

SpectralGerbil

Members
  • Joined

  • Last visited

Everything posted by SpectralGerbil

  1. Sorry, but I'm a little confused on which component you're referring to as the parent. Do you mean the one a level above the attribute I want to remove, or are you saying I should remove the entire tooltip processed in the event? Is there a particular method to going about doing that? Also, how would I view the full translation structure? I'm not familiar with doing so.
  2. Hello again. Things seem to be working great so far now, thanks to your help; I've been able to dig into the arguments and found the "generic.armor" attribute tooltips. However, how do I remove them from the TranslatableComponent arguments? There isn't a method to edit the arguments. Alternatively, if I need to redefine my own TranslatableComponent to replace the old one, how can I do so properly, passing the right amount of arguments and such?
  3. 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.
  4. Hello, I'll keep it short and sweet. I'm removing armor tooltips from armor for a custom defense system that's nearly finished. I am using ItemTooltipEvent to obtain each tooltip and check if it contains the +X Armor tooltip, and then remove that tooltip. It works however I would like to make it work across languages. (Searching for the phrase "Armor" will not work in other languages). After some research I've found I need to obtain the translation keys for parts of these tooltips, and I can then iterate them and remove tooltips that contain the translation key "attribute.name.generic.armor". However I'm digging through 1.17 documentation and cannot find a way to obtain translation keys from the tooltips. I believe I could convert the Components retrieved from the tooltips into TranslatableComponents, but cannot find a method that does this. Could someone with the proper knowledge tell me how I can achieve this? Edit: For some context, yes I plan on updating to 1.18.1 soon but would like to figure this out first.

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.