Stop a server with Villages&Pillages 2.0.0 from hanging on shutdown, by having its tree check read structures from the generating chunk instead of waiting on the server thread.
Villages&Pillages keeps trees from growing inside witch villages. In 2.0.0 for NeoForge 1.21.1, that check asks the server level for structure data from a world-generation worker thread. The worker waits for the server thread and keeps nearby chunks loaded. If the server stops during that wait, it can keep unloading chunks and never finish saving, so the server has to be killed. This happens on dedicated servers and in singleplayer worlds.
After Villages&Pillages' code has been applied, this mod rewrites that one lookup to read the structure data the generating chunk already holds, the way Villages&Pillages 1.0.x did through YUNG's API. Witch villages get the same trees as before. Positions outside the generating region are treated as having no structure, and other levels, such as a sapling growing on the server thread, keep the original lookup.
- One call, nothing added: no blocks, items, recipes, commands or options, no extra libraries, and none of Villages&Pillages' code bundled or copied.
- Server side: players joining a server do not need the mod on the client.
- If the check changes: on a later Villages&Pillages version without that call, the mod leaves the game as it is and writes one line to the log.
On a development server, 2,482 rewritten lookups were checked against the original call and none disagreed; witch-village structures were found in 15 of them. On a 490-mod All the Mods 10 server, all 20 shutdowns with the fix finished saving, while 3 of 13 earlier runs without it did not.
Villages&Pillages is required; there is nothing to configure.

Paid commissions for videos, streams and servers. Send me your idea: kuronami.mods@gmail.com

All Rights Reserved. Free to put in any modpack, on any platform, monetised or not - no permission needed, no credit required. Source is published so you can read exactly what it does. Source code: https://github.com/KURONAMI333/villages-and-pillages-hang-fix Bugs and questions: comment on the CurseForge page, or DM @kuronami333 on X.




