Minecraft Wiki
Advertisement

Inquiry on Villagers

I was directed here by Orthotope, and there isn't much more I can say outside of what I asked of him:

"The wiki says the Riches variable on Villagers is currently unused. However, in 12w26a, I suspect it is used. I traded with a villager several times, then right click traded. The Uses variable says it totaled 127 uses. At first, he was not adding new trades. After doing so may trades, he added new ones and didn't remove the original. Could you see if Riches is used now, please?"

Partially off topic, but I made a Villager Mob Spawner in 12w26a that does this: http://i.imgur.com/98Rgs.png Thought that might interest you. --MegaScience 01:06, 30 June 2012 (UTC)

The call hierarchy indicates that the Riches variable is never called, except when reading and writing NBT data, and when increasing it, all of which happens in the Villager class. In fact, the variable can't even be accessed outside the class, unless other classes can load a Villager's NBT data, and the Villager class is also the only class to contain a reference to "Riches", so that's not possible either.
In short, no, the Riches variable is still unused.
As far as the uses variable, it's only referenced 4 times within the Offer class, where it reads and writes NBT data, increments the value, and provides other classes the ability to read the variable. The call hierarchy of the method providing access to it indicates that the Villager class is the only one to actually do so, and it does that when it checks whether an offer's been used enough times to be removed.
So the uses variable has no special/previously-unknown purpose, or any interaction whatsoever with Riches. Also, since uses is an int, it can have a maximum of 2147483647, meaning that 127 isn't a special number for uses, either. If uses were a byte, then yes, 127 would actually happen to be its max.
Assuming you were trading the rightmost slot until uses hit 127, there's no surprise: the rightmost offer is never removed. Now that it is no longer the rightmost, if you try trading that offer again, it will be removed because you've reminded the game that it's (over)due for removal.
Also, the custom trader spawner thing is interesting; I'm glad Mojang has made this possible. I actually saw sethbling's video demonstrating MCEdit filters he made which can streamline the process of making things like that. Who knows, maybe someday Mojang will let us slap a mob's NBT data onto a spawn egg, allowing a dispenser to, say, dispense a special trader in the event that the original killed - though Resistance IV dramatically reduces the odds of that ever happening anyhow :p --WolfieMario 03:08, 30 June 2012 (UTC)
Advertisement