#I Didn't Want To Install A Mod So I Made My Own Durability Tooltip Script

41 messages · Page 1 of 1 (latest)

junior quiver
#

Hey, I don't know if someone remembers the script by Chief:
"IDWTIAMSIMMOEDS (I Didn't Want To Install A Mod So I Made My Own Enchantment Description Script)"

But this was my inspiration to create a little durability tooltip script, mostly bec I don't like that SuperMartijn's mod shows the tooltip under the mod_id (idk why I just don't like it).

This script will just show this little tooltip thing, you guys can ofc modify it to have other colors etc or only show it by pressing a key.
With tags, you can also use it for more tools than only the diamond sword.
this is of course a client script

warm grottoBOT
#

Paste version of IDWTIAMSIMMODTS.js from @junior quiver

junior quiver
#

I Didn't Want To Install A Mod So I Made My Own Durability Tooltip Script

narrow gate
#

😆

stark mesa
#

epic, i've been waiting for someone to make the IDWTIAMSIMMODTS script

hardy trout
#

is there an event that detects whether or not the player has advanced tooltip enabled?

#

with this code you get double tooltips

junior quiver
junior quiver
#

I think you can just change

text.add(Text.white(`${durabilityText}`));

to

if (!text.toString().includes("durability")) {
            text.add(Text.white(`${durabilityText}`));
worldly pewter
# junior quiver I think you can just change ```js text.add(Text.white(`${durabilityText}`)); ``...

i can confirm that this works

ItemEvents.tooltip(event => {
    event.addAdvanced('minecraft:diamond_sword', (item, advanced, text) => {
  //    if (event.shift) {
          const maxDurability = item.getMaxDamage();
          const currentDurability = item.getMaxDamage() - item.getDamageValue();
          const durabilityText = currentDurability === maxDurability 
            ? `${maxDurability}` 
            : `${currentDurability}/${maxDurability}`;
            if (!text.toString().includes("durability")) {
                text.add(Text.white(`${currentDurability} / ${maxDurability}`));
  //    }
    }})
  })
#

also if you want to do it with item tags insted you can

    event.addAdvanced('#c:tools', (item, advanced, text) => {
plush depot
#

For some reason it doesnt work for me

warm grottoBOT
#

╰( ͡° ͜ʖ ͡° )つ──☆:・゚˜”°•.˜”°• Many Help •°”˜.•°”˜*
Please provide a description of your issue with as much detail as possible. If you have an issue with a script provide the script. Explain what you can see happening and what you expect to happen. Be specific!

Tell us what is happening, we already know it "doesn't work".
Avoid using words like "it", tell us exactly what "it" is.
Don't assume anyone knows what you are talking about, be specific.

Provide screenshots or video of the issue if possible.

Provide the log.

cloud void
#

Make a ticket

worldly pewter
plush depot
#

This one with durability tooltip, I added it to client_script folder and doesnt show on items.

worldly pewter
#

Witch one there are like 3 in the thread if it’s mine then

#

??kjslogs

warm grottoBOT
# worldly pewter ??kjslogs

You can find your KubeJS client log in /minecraft/logs/kubejs/client.log.
If you are on 1.18 or 1.16 it will be called client.txt.
Please send it if asked, as it contains helpful information.

worldly pewter
#

And mc version

#

If it’s >1.19 then I can’t help

#

This script was designed for 1.19.2-1.20.4

#

??neversay

warm grottoBOT
# worldly pewter ??neversay

Never say 'it crashed', 'it errored', or 'it didn't work' without providing the full crash report, log, and scripts!

plush depot
worldly pewter
#

yeah it would i dont know how 1.21 works but i can try

worldly pewter
#

it almost always helps to send logs

vernal lance
#

whens the IDWTIAMSIMMODTS script gonna be added to curse and modrinth

worldly pewter
#

not how it works

narrow gate
#

IDWTIAMSIIAMTISS (I didn't want to install a mod so I installed a mod to install some scripts)

cloud void
#

More like ITLTIAKSSIIAMTIIFM (I'm to lazy to install a Kubejs script so I installed a mod to install it for me)

obtuse field
#

there's a way to get this work for all items?
paxels, swords, armours?

without need to put all the id's from the items

I've changed a little bit but still need's to put all the item we want to show the durability

let itemsWithDurability = [
    {
      id: "minecraft:diamond_sword",
      color: Text.red, // specific color for this item
    },
    {
      id: "minecraft:iron_sword",
      color: Text.green, // specific color for this item
    },
    {
      id: "minecraft:netherite_sword",
      color: Text.blue, // specific color for this item
    },
    {
      id: "infinity_nexus_mod:imperial_infinity_sword",
      color: Text.yellow, // specific color for this item
    }
    // add more items here if necessary
  ];

  for (let i = 0; i < itemsWithDurability.length; i++) {
    let itemConfig = itemsWithDurability[i];

    event.addAdvanced(itemConfig.id, (item, advanced, text) => {
      const maxDurability = item.getMaxDamage();
      const currentDurability = maxDurability - item.getDamageValue();

      // durability text (only if not been added yet)
      if (!text.toString().includes("durability")) {
        text.add(itemConfig.color(`${currentDurability} / ${maxDurability}`));
      }
    });
  }
worldly pewter
#

tags

worldly pewter
#

for tags like tools its #C:tools

worldly pewter
#

minecraft's modid is just "minecraft"

#

i dont entirely remember how to use modids but i know its possible