From 35b98633ba7189ea5451bbbf6459a388b4500c11 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Mon, 20 Jan 2025 05:06:14 -0800 Subject: [PATCH] Add thread check to YieldJobSite We cannot yield the job site if it is outside of the current region. Fixes https://github.com/PaperMC/Folia/issues/316 --- .../entity/ai/behavior/YieldJobSite.java.patch | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 folia-server/minecraft-patches/sources/net/minecraft/world/entity/ai/behavior/YieldJobSite.java.patch diff --git a/folia-server/minecraft-patches/sources/net/minecraft/world/entity/ai/behavior/YieldJobSite.java.patch b/folia-server/minecraft-patches/sources/net/minecraft/world/entity/ai/behavior/YieldJobSite.java.patch new file mode 100644 index 0000000..d3f8748 --- /dev/null +++ b/folia-server/minecraft-patches/sources/net/minecraft/world/entity/ai/behavior/YieldJobSite.java.patch @@ -0,0 +1,17 @@ +--- a/net/minecraft/world/entity/ai/behavior/YieldJobSite.java ++++ b/net/minecraft/world/entity/ai/behavior/YieldJobSite.java +@@ -33,7 +_,13 @@ + } else if (villager.getVillagerData().getProfession() != VillagerProfession.NONE) { + return false; + } else { +- BlockPos blockPos = instance.get(potentialJobSite).pos(); ++ // Folia start - region threading ++ GlobalPos globalPos = instance.get(potentialJobSite); ++ BlockPos blockPos = globalPos.pos(); ++ if (globalPos.dimension() != level.dimension() || !ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(level, blockPos)) { ++ return true; ++ } ++ // Folia end - region threading + Optional> type = level.getPoiManager().getType(blockPos); + if (type.isEmpty()) { + return true;