mircokroon / minecraft-world-downloader

Download Minecraft worlds, extend server's render distance. 1.12.2 - 1.21
GNU General Public License v3.0
1.25k stars 83 forks source link

Fix villager trades not saving in 1.19.4+ #603

Closed zomabies closed 1 year ago

zomabies commented 1 year ago

This PR aims to fix villager trades saving as shown in #554.

Additionally

Tested in 1.19.4

mircokroon commented 1 year ago

Looks good, what is the purpose of storing the location of the villagers? Is it only for the info messages?

zomabies commented 1 year ago

Thanks.

what is the purpose of storing the location of the villagers? Is it only for the info messages?

Currently, villager requires "right-hand" interaction to get trade list (similar to block entities with inventory). When disconnected/leaving chunk and villager get unloaded, and reloaded again (rejoin/re-enter chunk), it fetches the server version without trade list.

In this case, player need to perform interaction again to save the trades. It can become tedious when do not know if the trades is successfully saved unless search the relevant trades with NBT editor. Therefore, I handled it by storing the villager UUID and trades in a Map, similar to ContainerManager for handling block entities load/unload.

I not sure this is the best practice since entity with inventories do need such handling, it work on villager though.