#Tooltip modification

76 messages · Page 1 of 1 (latest)

muted path
#

Is there any way to adjust this to default hide and show by pressing shift?

errant hatchBOT
#

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

muted path
#

Any one has ideas? plz help

tawdry sage
#

This is a rough version of a script that works. There are definitely some things that can be improved, but you can do it yourself. It works for me in 1.20.1 fabric. ```ItemEvents.tooltip((tooltip) => {
tooltip.addAdvanced(
'minecraft:diamond_chestplate',
(item, advanced, text) => {
//store every tooltip element in an array that contains 'Armor' or 'Body'
const storedTextArr = [];
for (let i = 0; i < text.length; i++) {
//console.log(text.get(i).string); debug log
if (/Armor|Body/.test(${text.get(i).string})) {
//console.log(text.get(i)); debug log
storedTextArr.push(text.get(i));
}
}

  //remove every tooltip element that is stored in the storedTextArr
  text.removeIf((el) => {
    let remove = false;
    storedTextArr.forEach((storedEl) => {
      if (el == storedEl) remove = true;
    });
    return remove;
  });

  //add the shift to tooltip
  if (!tooltip.shift) {
    text.add(text.length - 1, [Text.of('[Shift]').gold()]);
  } else {
    for (let i = 0; i < storedTextArr.length; i++) {
      text.add(text.length - 1, [storedTextArr[i]]);
    }
  }
}

);
});```

muted path
#

Thank you!

valid pecan
tawdry sage
#

could you illustrate it with pictures? I don't know what the problem is.

#

You dont want to show any attribute wehen pressing shift ?

valid pecan
#

Sure! As of right now, I have another script that removes both attack damage and attack speed from the default tooltip (shown above). However, with this script added they re-appear when I hold shift. Can I make them exempt from showing with Shift?

tawdry sage
#

So you want these items that no longer have any atk and speed attributes to be excluded from the shift? So no more shift at all or that all other attributes except speed and atk are displayed there, such as crit?

#

"No shift at all" can be solved using an item list and "everything except atk and speed" by merging your first script with mine.

valid pecan
#

Right I want all my extra attributes to show but except for attack speed and attack damage. I merged my script with yours and they still appear in the Shift tooltip

tawdry sage
#

Try this ```js
ItemEvents.tooltip((tooltip) => {
//const swordArr = Ingredient.of(/helmet/).itemIds;
const swordArr = Ingredient.of(/sword/).itemIds;

swordArr.forEach((itemId) => {
tooltip.addAdvanced(itemId, (item, advanced, text) => {
//store every tooltip element in an array that does not contain Attack Damage/Speed and starts with space/+/- int
const storedTextArr = [];
for (let i = 0; i < text.length; i++) {
//console.log('DEBUG 01', text.get(i).string); //debug log
if (/Attack Damage|Attack Speed/.test(text.get(i).string)) continue;
if (/^(+|-| )\d/.test(text.get(i).string)) {
//console.log('DEBUG 02', text.get(i).string); //debug log
storedTextArr.push(text.get(i));
}
}

  //remove every tooltip element except for the item name
  let name = text.get(0);
  text.removeIf((e) => e != name);

  //add the shift to tooltip
  if (!tooltip.shift) {
    text.add(text.length, [Text.of('[Shift for bonus stats]').gold()]);
  } else {
    for (let i = 0; i < storedTextArr.length; i++) {
      text.add(text.length, [storedTextArr[i]]);
    }
  }
});

});
});```

#

And disable the other script that removes speed and attack damage

valid pecan
#

Hmm I tried this and it does the same thing as my old script. The attack damage and attack speed are still there. I'm not sure why it stores every other apotheosis attribute in the shift tooltip.

#

let me see if I can provide a screenshot

potent portalBOT
#

Paste version of tooltip_ss.pdf from @valid pecan

valid pecan
#

sorry it's a pdf can't ss in game when shifting haha

tawdry sage
#

The problem is I don't have the mod (apotheosis) myself. It works with the Aquamirae mod in my game.

#

Without script

#

With script

#

I can only imagine that your attributes are not called Attack Damage/Speed, but something else. (in your game)

valid pecan
#

It's not any different. I also have AttributesLib and I can see that the attack speed and damage attributes are still the defaults

#

For the golden sword in that picture it's default attack damage is 5

#

So when I'm shifting it actually shows the base damage and not the modifier

tawdry sage
#

Can you send me a before and after picture?

#

And is my script the only script that modifes tooltips in your game ?

valid pecan
#

Ooh I'm not sure

#

let me double check

tawdry sage
#

And to be safe. The way it is in my screenshots, is that how it should be?

valid pecan
#

Yes

#

How did you ss while shifting?

tawdry sage
#

I just pressed f2 ^^

valid pecan
#

weird mine doesn't like me ig

tawdry sage
#

I have no idea why that is the case for you

valid pecan
#

I rebound the key and it's because my f2 is paired with the function key haha

#

this is actually with the code after I removed my other scripts

tawdry sage
#

Ok, I'm starting to understand the error. You seem to have several Attack Damage text elements

#

Can you send me another picture without a tooltip script. So what the item default looks like

#

Because there is a green, a red and a blue attack damage in your picture

valid pecan
#

True I'm also realizing that your script isn't working for me because I don't know where to put the item id's

tawdry sage
#

const swordArr = Ingredient.of(/sword/).itemIds this should get every item id that contains sword in its id name

valid pecan
#

Okay that fixed it

#

smh

tawdry sage
#

Fixed what ?

#

Everything ? 🙂

valid pecan
#

yes

#

😆

#

thank you!

tawdry sage
#

Ok, luckily that was easier than expected

valid pecan
#

You always follow through thanks for the help my friend 👍

tawdry sage
#

No problem. Have fun with your modpack

valid pecan
#

Do you think there's a way to get rid of the 'Two Handed' text in the tooltip?

#

Because that's not an attribute that's hardcoded

tawdry sage
#

If you remove the / in this code //console.log('DEBUG 01', text.get(i).string); //debug log, all text elements will be displayed in your client log. You have to see if it is listed there. If so, it should be doable.

valid pecan
#

Okay

#

Can't touch it, thanks for your help

tawdry sage
#

youre welcome ^^

valid pecan
#

Ugh sorry one more question, is there a way to move the ttoltip down a line?

tawdry sage
#

Yes

#

I'm on my handy right now. can help you with that later

valid pecan
#

ok ty

tawdry sage
# valid pecan Ugh sorry one more question, is there a way to move the ttoltip down a line?

Ok if you just add a space text element after the "removing" it should work. text.add(1, [Text.of(' ')]); ```js
ItemEvents.tooltip((tooltip) => {
const swordArr = Ingredient.of(/sword/).itemIds;

swordArr.forEach((itemId) => {
tooltip.addAdvanced(itemId, (item, advanced, text) => {
//store every tooltip element in an array that does not contain Attack Damage/Speed and starts with space/+/- int
const storedTextArr = [];
for (let i = 0; i < text.length; i++) {
//console.log('DEBUG 01', text.get(i).string); //debug log
if (/Attack Damage|Attack Speed/.test(text.get(i).string)) continue;
if (/^(+|-| )\d/.test(text.get(i).string)) {
//console.log('DEBUG 02', text.get(i).string); //debug log
storedTextArr.push(text.get(i));
}
}

  //remove every tooltip element except for the item name
  let name = text.get(0);
  text.removeIf((e) => e != name);
  text.add(1, [Text.of(' ')]);

  //add the shift to tooltip
  if (!tooltip.shift) {
    text.add(text.length, [Text.of('[Shift for bonus stats]').gold()]);
  } else {
    for (let i = 0; i < storedTextArr.length; i++) {
      text.add(text.length, [storedTextArr[i]]);
    }
  }
});

});
});```

valid pecan
#

Hey again, is there a way to make it so it doesn't include enchantments?

tawdry sage
valid pecan
# tawdry sage you need to explain this in more detail

As of right now you’ve helped me make it so that when I specify an item group every stat besides attack damage, speed, reach, +, and - get stored in a shift tooltip. However when I’m using this script it also removes any enchantments (I.e. sharpness) from an enchanted item’s tooltip. Is there a way to add enchantments to a different blacklist like we did with attack damage, speed etc. so that enchantments still show up on the vanilla tooltip?

tawdry sage
#
ItemEvents.tooltip((tooltip) => {
  const swordArr = Ingredient.of(/sword/).itemIds;

  swordArr.forEach((itemId) => {
    tooltip.addAdvanced(itemId, (item, advanced, text) => {
      //store every tooltip element in an array that is not blacklisted
      const storedTextArr = [];
      for (let i = 1; i < text.length; i++) {
        //console.log('DEBUG ALL', text.get(i).string);
        //blacklist regex, every string here will be removed from the tooltip
        if (!/Attack Damage|Attack Speed/.test(text.get(i).string)) {
          //console.log('DEBUG STORED', text.get(i));
          storedTextArr.push(text.get(i));
        }
      }

      //remove every tooltip except for the item name and add a space
      let name = text.get(0);
      text.removeIf((e) => e != name);
      text.add(1, [Text.of('').darkRed()]);

      //add the shift to tooltip
      if (!tooltip.shift) {
        text.add(text.length, [Text.of('[Shift]').gold()]);
      } else {
        storedTextArr.forEach((textEl) => {
          text.add(text.length, [textEl]);
        });
      }
    });
  });
});```
#

If there's something else you don't want to have in the tooltip, just add it to the regex

tawdry sage
valid pecan
tawdry sage
#

Then you need a blacklist for everything you dont want and a whitelist for everything in the default tooltip. Because i have no idea how to detect if a tooltip is an enchantment

valid pecan
#

Okay will do thank you

valid pecan