#Need help with a script please.

3 messages · Page 1 of 1 (latest)

dapper willow
#

Hello Everyone. Im trying to get the apotheosis:rarity="apotheosis:mythic" disblayed int eh 2nd line of my tooltip and that the code i came up with but its not showing. `// kubejs/client_scripts/apotheosis_rarity_tooltip.js
ItemEvents.modifyTooltips(e => {
e.modifyAll(b => {
let item = b.item;
// Überprüfen, ob das Item und seine Komponenten vorhanden sind
if (!item || !item.components) return;

// Holen der Raritätskomponente direkt
let rarityComp = item.components.get('apotheosis:rarity');

if (rarityComp) {
  // Wenn rarityComp ein Objekt oder String ist, konvertiere es zur ID
  let rarityKey = rarityComp.toString();

  let rarityMap = {
    'apotheosis:common': 'Common',
    'apotheosis:uncommon': 'Uncommon',
    'apotheosis:rare': 'Rare',
    'apotheosis:epic': 'Epic',
    'apotheosis:legendary': 'Legendary',
    'apotheosis:mythic': 'Mythic',
    'apotheosis:ancient': 'Ancient'
  };

  let rarityDisplay = rarityMap[rarityKey];
  if (rarityDisplay) {
    // Fügt die Zeile an Position 1 (unter dem Namen) ein
    b.insert(1, Text.of('Rarity: ' + rarityDisplay).gold());
  }
}

});
});`

clear turretBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

dapper willow
#

Its based on this little test code wich show "Rarity: TEST" in the 2nd line of the tooltip. ItemEvents.modifyTooltips(e => { e.modifyAll(b => { b.insert(1, Text.of('Rarity: TEST').gold()); }); });