Skip to content

Commit

Permalink
Add thread check to YieldJobSite
Browse files Browse the repository at this point in the history
We cannot yield the job site if it is outside of the current
region.

Fixes #316
  • Loading branch information
Spottedleaf committed Jan 20, 2025
1 parent b54ba0d commit 35b9863
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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.<GlobalPos>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<Holder<PoiType>> type = level.getPoiManager().getType(blockPos);
if (type.isEmpty()) {
return true;

0 comments on commit 35b9863

Please sign in to comment.