=== NOTICE ===
This data pack has been rewritten and renamed to Villager Job Fix to accommodate new features. Here's the new data pack with new quality of life features: https://www.curseforge.com/minecraft/customization/villager-job-fix
=== Showcase ===
=== About the Data Pack ===
The purpose of this data pack is to connect villagers to nearby work stations - ones that they can actually work with from their current position. This enables you to do trade centers and villager cages without having to worry about them getting a work station that's too far from their position.
The data pack allows you to set the closest villager's job site to one of 17 positions around him.
- If no trades have been made, the data pack will set his job site and change profession accordingly;
- If you have traded with the villager already, the data pack only updates the job site.
The closest villager will always be targeted (10 block radius). So approach a villager, place a work station adjacent to him, and use the command "/trigger cvjs_fixJobSite".
The workstation detection order is as follows:
- Below villager's feet;
- Then the 8 blocks around his legs: N > S > E > W > NE > SW > SE > NW;
- Finally, the 8 blocks below the previous 8 (remember we already checked the middle one below his feet): N > S > E > W > NE > SW > SE > NW;
=== Notes ===
The entity used for the highlight of the connected Job Site is visible for a brief moment due to a very old bug: https://bugs.mojang.com/browse/MC-88181
Unfortunately Mojang never fixed it so there isn't much I could do. There might be some ways work around it but that'd result in adding more lines of code - for now I'd rather have a cleaner and more efficient code than add more junk just to work around the bug.
=== Links ===
YouTube - ScorchedPsyche
Downloads - CurseForge
Support for Data Packs - CraftEra
Reddit - CraftEra