Villagers do not properly keep track of the last time they restocked, neither the number of times they have restocked in the day. This causes villagers indefinitely restocking each time they visit their POI during their work hours. This happens with each villager once the world has passed a a half-day of gametime.
- Let the world gametime reach at least 12,000 ticks (/time query gametime to check).
- Spawn a villager in an empty superflat world with access to a POI
- Trade with this villager during work hours
The villager will restock every time he works at his workstation, leading to the possibility of abusing his trades (Laura's 2nd screenshot shows 4 stacks of emeralds obtainable in one day), even while the GUI is still open ([Helper] Johnibur's video: 2019-07-23 12-11-49.mp4).
As a result of the restocks not being tracked, the demand being reduced at every restock will absurdly go down, in the wrong direction (Laura's 1st screenshot, making the prices not affected by an excessive use of the same trades.
The nbt values LastRestock and RestocksToday always stay at 0.
Code analysis by [Helper] Johnibur:
This method (own mappings) from the Entity Villager class performs the restocking (set trades use values to 0) and set tracking values which are used for the hasNotAlreadyRestocked() condition further below:
It is called each time the villager works at his workstation, provided the following requirement is met:
The method isOutOfStock() checks whether any stock has been depleted:
Yet, the restock can already be potentially done inside the method called for demand:
This leads to isRestockNeeded() always be false once a certain amount of gametime has passed, because the restock is already done in the call for demand methods, but not tracked at all. Thus properly restocking is not possible.