#Mass renaming items based on display name

9 messages · Page 1 of 1 (latest)

humble crag
#

Hey all, I've been racking my brain with this issue for the past day, including browsing through the other posts here.
I'm trying to rename a whole bunch of items with Palm in their name to Tough + their previous name.
So far while trying to debug I've got something like this:

// priority: 100
ClientEvents.lang('en_us', e => {
    const rename = (item, newName) => e.add(Item.of(item).item.getDescriptionId(), newName)
    Ingredient.of(/beachparty:.*palm.*/).stacks.forEach(item => {
        let prevName = Text.translate(Item.of(item).displayName).string
        console.log(prevName)
        //console.log(prevName.replace('Palm', 'Tough Palm'))
        //rename(item.id, prevName.replace('Palm', 'Tough Palm'))
    })
})

However, when I then load the game, rather than logging the actual name, it logs

[10:34:00] [Render thread/INFO] [KubeJS Client/]: rename.js#8: translation{key='chat.square_brackets', args=[empty[siblings=[translation{key='block.beachparty.palm_sign', args=[]}]]]}[style={color=white,hoverEvent=HoverEvent{action=<action show_item>, value='net.minecraft.network.chat.HoverEvent$ItemStackInfo@7afb7266'}}]

Which I would assume is caused by Text.translate trying to do its thing too early. (It's line 8 because I removed 2 excess lines from the code snipper above)
If I then go into a world and try to reload via F3+T, however, I end up getting the same thing.
Uncommenting the 2 lines that I commented out gladly loads the item name. Except, you know. Yeah.

Any ideas for what do?

waxen socketBOT
#

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

humble crag
#

(of note is i've also tried rename(item.id, 'Tough ' + prevName, to similar results)

#

Mass renaming items

#

Mass renaming items based on display name

humble crag
#

Is just reading the lang files of the mod in question my best bet here? Pain

wooden trellis
#

hey @humble crag im trying to do a very similar thing; have you figured out a solution yet?

#

(if not and I figure out a solution I'll let you know too)

humble crag
#

nothing figured out :(