Changing Tool Names

Wavebrother

New Member
Jul 29, 2019
171
0
1
I would like to change the name and texture of my tool when it gets a certain enchantment. For example, I would like to change the name to "Silky Ender Pickaxe" when it gets silk touch. Anyone know how I would do this?
 

ljfa

New Member
Jul 29, 2019
2,761
-46
0
Should be possible by overriding the getUnlocalizedName function. It takes an ItemStack as parameter so you can look at its NBT data and act accordingly.
And you can do the same thing for the texture with getIcon.
 

VapourDrive

New Member
Jul 29, 2019
536
-8
1
I would be wary about changing the unlocalised name, not a great idea. I would recommend using getItemStackDisplayName - also uses an itemstack as the parameter and only changes the on screen name that the player sees. The "identity" of the item changes with the unlocalised name and you may not want that. Also if you change the display name and still want to keep it localized (which is good) you need to manually set up the localization.
 

ljfa

New Member
Jul 29, 2019
2,761
-46
0
I would be wary about changing the unlocalised name, not a great idea. I would recommend using getItemStackDisplayName - also uses an itemstack as the parameter and only changes the on screen name that the player sees. The "identity" of the item changes with the unlocalised name and you may not want that. Also if you change the display name and still want to keep it localized (which is good) you need to manually set up the localization.
Oh good to know! Thanks!
 

Elder Jürd

New Member
Jul 29, 2019
16
0
0
Also... you could add the adjective as a tooltip looking like:

-------------------
Ender pickaxe
Silky
-------------------
That's pretty neat.