While attempting to document which Career IDs pertain to which subclasses of Villager, I noticed that the game was setting Careers to overflowed numbers.
Example: Butcher/White Apron villagers have Leatherworker and Butcher subclasses. Leatherworker is Career 0 and Butcher is Career 1. Upon testing the NBT of summoned Villagers, I noticed the game was setting White Apron villagers to Career 2. Similarly, I found this issue with Blacksmiths, whereas they'd be set to Career 3 when they only have 3 careers (Tool Smith: 0, Armorer: 1, Weapon Smith: 2).
While this normally isn't a problem as the game cycles back through the list when numbers above usual are used, this presents an issue with systems which check the NBT of entities. You could expand the checks for multiple values, but considering these values normally shouldn't be used in the first place, I'd find this an error.
It is difficult to test this. In summoning villagers, the game sometimes accepts given Career NBT and at other times will randomly set the Career NBT. However, these are the two base commands I use for summoning and testing villagers:
/summon Villager ~1 ~-1 ~ {Profession:4,Career:1}
/testfor @e[type=Villager,r=3] {Career:1}
You would change the Career:# to whichever you wish and test for villagers nearby. I built a command block system around this for automation, and can provide a world download if needed. I would have to generate a new world and rebuild it to keep the filesize down, though.
Attachments
Comments 11
is the game ever actually accepting the given Career tag? or is it just randomly assigning it and occasionally lining up with what you're trying to get?
In general, it seems like half the time the game sets the career itself, while the other half it will allow me to set the career via the NBT. There's a lot of problems going on here.
I have just set up something similar after seeing your board. I noticed that the villager's NBT tag Career
was changing after I opened the trade window making it totally useless to set the career for any villagers. I hope this is not intentional.
Is this still a concern in the current Minecraft version 14w11b / Launcher version 1.3.11 or later? If so, please update the affected versions in order to best aid Mojang ensuring bugs are still valid in the latest releases/pre-releases.
I just checked, and while the issue is slightly different, it's actually helped me understand it better. As you might know, when the game finds a Villager from before the Career system, it will attempt to update it. It seems originally, this could happen when a Villager spawns/is summoned. Now, the Villager Career is correct until accessed. When the Villager is accessed, the game sometimes checks the Villager. It seems just the Career ID isn't enough, so the game believes the Villager is outdated and redoes their data, including Career. When it finishes, it increments the Career ID by 1 instead of setting it to 1. This is what causes Villagers to be set to invalid IDs outside the normal range, as well as changing the Career set by the player. Updated affected versions.
I don't know my way around all the NBT stuff, but in 14w32d I just summoned several villagers, and it seems to ignore the Career I specify, and just give me a random Career. Using: /summon Villager ~ ~ ~ {Profession:3,Career:1}
Well it seems the issue is just that when checking if a villager is updated, it checks multiple tags. As such, applying one tag isn't enough. If it doesn't find all the applicable tags, it tries to update the villager manually and then increments the career number, which can cause overflow among other issues. It's just a problem where the Update Villager code hyperactive, and ignores some tags in the process. Shouldn't be difficult to fix, just need to finish the understanding of it.
Is this still a concern in the current Minecraft version 1.8.1 Prerelease 3 or later? If so, please update the affected versions in order to best aid Mojang ensuring bugs are still valid in the latest releases/pre-releases.
Adding a picture of the system I had set up. Sometimes summoned villagers would keep using the Career NBT, but other times the game was overwriting it for some reason, so I had made this board of 6 digits to tell me what villager I had. Then I noticed it was setting overflow.
The villager is a Blacksmith by Profession. There are 3 Careers for Blacksmith, but it was given Career 3 (0-2 are normal range), so it is a Tool Smith. While this is functional, any systems checking NBT of villagers won't detect properly since this number normally shouldn't be possible.