I was explicitly referring to fenhl's comment about the end portal position offset which happens occasionally.
I am completely aware of why the nether portal offset exists. after all it was me who figured that out by spectating what happens 😉
To correct Fenhl, this does not happen always. I would assume that a player's delay to the server has a role in whether he will get offset or not.
you are indeed right, but that also could be fixed by triggering the whole trade refresh to the event that a player opens the trade window.
In that case the check for uses >= maxUses would only be necessary for scenario 1 from my previous post.
Actually the first trade gets generated on opening the trade window to a villager for the very first time.
To keep the delay in if desired, there could be timeframe of 40 ticks or so in which the Villager does not interact with the player. This would then have to be implemented in a way that it does not break the villager with that forced idle time due to the same reasons as stated above.
There are actually scenarios in which can make the villagers "break":
1.) As described in the description of this bug report the first trade breaks.
This happens as follows:
The villager has a certain trade to start with, for instance a librarian offers 1 emerald for 24 paper.
You trade with the villager and close the trade window. A brief moment after closing the villager will update his trades. As he chooses randomly from all the trades he can possibly offer, it can happen that he chooses the paper trade again, but this time for 27 paper per emerald.
Since the 27 Paper per Emerald trade is rated worse than the 24 paper per emerald he does not replace it and will therefore not replace the trade. Note that this only happens on the first trade slot.
2.) The Villager has multiple trades:
You trade with the villager and use up all the trades in the last slot. Then you close the trade window.
If now for whatever reason the villager becomes unloaded before he is able to update his trade list his last trade will not be refreshed.
"becoming unloaded" includes
-the server or in single player client crashing.
-leaving the dimension unless the villager is in the spawn chunks or there is another nearby player to keep the villager loaded.
-leaving the game which will break the villager even in the spawn chunks in single player and in multiplayer with the exceptions mentioned above.
For every single trade in his list the villager has the two attributes
uses
and
maxUses
While uses < maxUses you are allowed to trade with the villager.
For uses = maxUses he will refuse to do that particular trade with you again.
If now one the above scenarios occurs the trade in the last slot can never be used again which makes this villager useless
which can be very frustrating if you as Tim Wilson described in his post. In order to unlock all the trade on a blacksmith you can estimate around 2.5 stacks of emerald blocks which requires a lot of trading to begin with.
In my opinion the most reliable and easiest fix would be to check
if(uses >= maxUses) on opening the trade window and set maxUses = uses + 1 in that case.
Since my description is the most detailed next to (https://mojang.atlassian.net/browse/MC-749?focusedCommentId=49233&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-49233) which covers the 2nd case described, I would appreciate if the reporter or a moderator could add this information to the report's description in order to clear things up.
@Ezekiel I have to strongly disagree here. If the client crashes for any reason, the result of the broken villager is the same. Same goes for servers with the little upside that, if trading with the villager in the spawn chunks, it is safe from breaking unless the server crashes. While outside the spawn chunks it is an option to have a second person stand nearby to keep the villager loaded, this still only applies to multiplayer.
You sure can pay close attention that you keep your villagers loaded until they finished updating their trades IF you are aware of the possible problem described above. However, you can safely assume that more than 95% of all Minecraft players do not know this bug and those, who encounter it, will very likely get frustrated.