CraftTweaker

CraftTweaker

177M Downloads

1.21 | Vanilla Rarities override modifyTooltip function

ValeriaeWasTaken opened this issue ยท 1 comments

commented

Issue description

If an item has a rarity with a colored name any attempts to modify its tooltip will not work

Steps to reproduce

Change an items rarity, then try to use modifyTooltip() on it

Script used

https://pastebin.com/K1w9Dz9S

The crafttweaker.log file

https://gist.github.com/ValeriaeWasTaken/8bad8857b42329ce964a4185f8679c7f

Minecraft version

1.21

Modloader

NeoForge

Modloader version

21.0.42

CraftTweaker version

20.0.13

Other relevant information

No response

The latest.log file

https://gist.github.com/ValeriaeWasTaken/8bad8857b42329ce964a4185f8679c7f

commented

I'm unable to reproduce this, I used the following script:

<item:minecraft:gold_nugget>.definition.setJsonComponent(<componenttype:minecraft:rarity>, "uncommon");
<item:minecraft:gold_nugget>.modifyTooltip((stack, tooltip, context, flag) => {
    tooltip.insert(1, Component.literal("This is a new line"));
});

which gives:
image

Just a note that the script you provided is invalid, as .getDefaultInstance() does not exist on IItemStack, you want to replace that with .definition instead.