#Adding text to tooltips with ids generated from a set

9 messages · Page 1 of 1 (latest)

tawny gust
#

In short, I have the additional lanterns mod running (adds many different lanterns for all dye colours and materials); and I would like to remove many of the permutations of the lanterns from JEI, and add info to the tooltips of the remaining ones to say that they can be dyed so users know the options exist without them being listed exhaustively. I have a list of colours and materials and removal from JEI works just fine, however I can't seem to get things working when it comes to adding info to the tooltip. The current iteration of the code looks like:

ItemEvents.modifyTooltips(event => {
    
    lantern_mats.forEach(material => {
        const itemId = `additionallanterns:${material}_lantern`;
        console.log(`Processing: ${itemId}`);

        event.modify(itemId, tooltip => {
               console.log(`Adding tooltip for: ${itemId}`);
               tooltip.add(['Can be dyed']);
            
        });
    })
});

And this appears to just be adding the text lantern_mats.size times over to every item in the game. But based on the existing documentation for 1.21 I'm not sure what's going on here.

JS isn't a language I'm too familiar with so there's an element of figuring things out as I go on my part here, but any pointers on the best way to do this would be appreciated.

cursive idolBOT
#

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

burnt dawn
#

try

ItemEvents.modifyTooltips(event => {

    lantern_mats.forEach(material => {
        const itemId = `additionallanterns:${material}_lantern`;
        console.log(`Processing: ${itemId}`);

        event.add(itemId, 'Can be dyed')
    })
});
#

And then also check to make sure lantern_mats is correct, and holds the information you want

#

currently, tooltip.add is adding that tooltip to every item in the game

#

and because its running for every lantern mat material it adds that many lines to every item in the game

#

you forgot to specify the item using itemId

#

Sorry for the long response time @tawny gust

tawny gust
#

Thanks for the reply. I'm afraid the code you sent has the same problem - it just adds "Can be dyed" to every item in the game. Just copying it across verbatim had the same issue.