setDisplayName not working?
JaddotWuzHere opened this issue · 7 comments
Intro:
I want to change the display name of an item in Minecraft but for some reason it's not working when I launch Minecraft.
Issue Description:
So I loaded up a bunch of compatible mods with CraftTweaker (if a mod isn't compatible in some way please tell me), and when I ran the script to change the display name of Dirt in Minecraft to 'Test', nothing happened. The other scripts I wrote worked fine, such as hiding items in JEI, custom recipes, etc. But not the name change. I was wondering if this is a bug or I messed up the script somehow.
What happens:
There was no error code in the chat when I launched Minecraft, but the Dirt I tried to change to 'Test' didn't work, it just stayed Dirt.
What you expected to happen:
The Minecraft Dirt item display name is changed to Test
Script used:
https://gist.github.com/Jason-Ding-Programs/b082a5eda19c6f79dd78979ec5474986
crafttweaker.log file:
https://gist.github.com/Jason-Ding-Programs/a4850db3c298acf029e38fc6d6a4f14f
Environment:
I'm not sure what this is, but I'll post a file of my latest.log as a gist:
https://gist.github.com/Jason-Ding-Programs/a8606be72ba88d800ad2da73f1e3e990
- Minecraft Version: 1.16.4
- Forge Version: forge-35.1.37
- CraftTweaker Version: 1.16.5-7.1.0.110
- Are you using a server: No, singleplayer world
- If yes, does the client have the exact same scripts?
Game log:
I'm not sure where to find this, please tell me.
setDisplayName
only changes it for that item instance, so if you used it in a crafting table recipe, it would output the item with the name there.
Currently CraftTweaker in 1.16 does not have a way to mass change names. I suggest you look into lang files for that.
maybe renaming it to withDisplayName is better. thinking
Yea, I'm not sure what I was thinking when I added that, fairly sure it was the first thing I added to test actions.
I'm happy to add a withDisplayName
alias for now, but that method would still exist (until maybe 1.17 were we introduce a breaking change)
so withDisplayName
would work? Or did I not understand correctly...? I'm confused
Using setDisplayName only changes the display name of that one item, it does not give the item a new localization entry.
Think of it that way: When you craft an iron sword, it's name is iron sword
. If you use the anvil to change the item's name to iron cutter
, the item that you have in your hand will be named "iron cutter". However, all other iron swords would still have the normal name.
Using setDisplayName
(and later withDisplayName
as well) only rename a single item, so it does the same as an anvil would. You can use that for example for recipe results, where you return an item with a special name.
If you want to rename every instance then you would need to change the item's localization entry.
That can be done by using a resource pack.