-
-
Notifications
You must be signed in to change notification settings - Fork 4
ZenScript
Usually, when you want to replace an item's default name, you would do it like this:
<minecraft:fishing_rod:*>.displayName = "Ancient Fishing Rod";
What this does is getting that item's original lang key and replacing its value with the designated String.
The problem is, it'll replace it with that String, whatever the language the client is using.
Instead, I recommend creating a .lang file just for your custom item names, adding that item's lang key and putting your desired name on it, like this:
item.fishingRod.name=Ancient Fishing Rod
Keep in mind, Minecraft manages language keys as follows:
- Read all lang keys inside Minecraft's JAR, from first to last, as they appear.
- Load each mod's JAR name in alphabetical order, and read its
.langfile.
Note: If the Minecraft instance has theResource Loadermod, theresources/minecraftfolder gets read before all mods. Then each mods'.langfile, then that mod's correspondingresourcessubfolder. - Load each Resource Pack from bottom to top, as they appear in the Resource Packs page.
On each step, if Minecraft finds a lang key that previously read, it updates its HashMap with the new value.
This means you can override an existing lang key's value with your desired value.
In the case of the mod
Aquaculture, it uses the exact sameitem.fishingRod.namelang key for its custom wooden Fishing Rod, as Vanilla's Fishing Rod. That's why if you create your lang key inside theresources/minecraftfolder, it'll get replaced by a mod if it has the same lang key, and so on.
Therefore, if you create a folder starting with zz and the name of the folder, for example: zzscripts, Minecraft will read your .lang file last, effectively overriding the desired lang key, without worrying which mod it belongs to.
But sometimes, there are items whose lang key are not easy to find.
In that case, use the game.localize function:
<notreepunching:cobblestone/basalt>.displayName = game.localize("tile.notreepunching:cobblestone.basalt.name","en_us");
The 1st argument is your language key, and the 2nd argument is a language code.
The item will use your specified lang key, effectively becoming translatable.
Don't worry about the
"en_us". Your name will be displayed in the current language.
Usually, when you want to add a description to an item's tooltip, you'll do it like this:
<minecraft:fishing_rod:*>.addTooltip(format.red("Only used for crafting!"));
You can use the game.localize function here as well:
<minecraft:fishing_rod:*>.addTooltip(game.localize("tooltip.scripts.onlycrafting","en_us"));
And freely format your text inside the lang key.