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?