The bug
Client-side an incorrect villager career name might be displayed when the CustomNameVisible
tag of a villager is set to true
but no CustomName
is set.
In the attached screenshot
you see a "Shepherd" (GUI title and trades) with the name "Fletcher".
How to reproduce
Use the following command and compare the shown name with the trades and the name in the GUI
/summon villager ~ ~ ~ {CustomNameVisible:1b,Profession:0,Career:3,CareerLevel:1}
Note: This might require multiple tries since the client could randomly pick the correct Career
.
Code analysis
Based on 1.11.2 decompiled using MCP 9.35 rc1
The Career
value of a villager is not send to the client, therefor it randomizes it. Additionally the client should very likely not call the method net.minecraft.entity.passive.EntityVillager.populateBuyingList()
.
Linked issues
relates to 1
Attachments
Comments 9
This is probably due to the mechanics of the CareerLevel tag. If I'm not mistaken, this value begins at 0 for vanilla-generated villagers. The first time the trading GUI is opened, the Career is reset, trades are re-generated, and the CareerLevel is bumped to 1. You can verify this by examining the entity data of a newly generated villager before and after the trading GUI is opened for the first time.
Reviewing protocol changes to 18w50a, villagers have different entity metadata (as do zombie villagers) and there's a new metadata serializer replacing what was just the profession that has 3 values. I'm guessing that it's profession, career, and "level" (which apparently is new, but I haven't investigated), but I haven't actually looked at the relevant code beyond what burger displays. But this is probably fixed, I just need to look further.
Fixed in a very simple way: careers simply do not exist anymore, and professions were flattened out (and also put into a registry). The entity metadata I found corresponds to the VillagerData
tag of the villager (so all of it is sync'd), which looks like the following for example:
{VillagerData: {level: 1, profession: "minecraft:librarian", type: "minecraft:plains"}}
I can also confirm this, I summoned a NoAI-Librarian months ago into a test world, and just set its entitydata to CustomNameVisible to true, and it tells me it is a Cartographer (but the trades and GUI name are Librarian).
Which reminds me I thought it was a bug in a mod and not Vanilla's fault, but when I played with a 1.10.2 mod that also shows the careers of Villagers, it was often mistaken, for example it displayed me a Villager as a Fletcher, but it was a e.g. Fisherman in his name and trades - now I know why that is, the mod displayed the career name correctly, but the actual career, trades and GUI name were deviating from it.
If I recall correctly, it only does that within the possible careers of the Villagers, so e.g. an Armorer could never have the name of "Librarian", just Tool or Weapon Smith.