From c0631fd5cd529bac79fee550d89106d528afe84b Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Sun, 9 Jul 2023 18:49:45 -0700 Subject: [PATCH] Do not erase job site memory when not in tick thread region The intention behind erasing the memory was to match the case where the villager would lose. However, there may not be any competitors in which case the villager would never lose. Instead, the new behavior is to behave as if the villager was not loaded. Fixes https://github.com/PaperMC/Folia/issues/64 --- patches/server/0003-Threaded-Regions.patch | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/patches/server/0003-Threaded-Regions.patch b/patches/server/0003-Threaded-Regions.patch index bb6bade..454f1ce 100644 --- a/patches/server/0003-Threaded-Regions.patch +++ b/patches/server/0003-Threaded-Regions.patch @@ -17861,16 +17861,15 @@ index a2de99709ce14303a309806c683da6b3548659c1..082b0594d5de2e952e0b2b64e76c1db3 } diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/PoiCompetitorScan.java b/src/main/java/net/minecraft/world/entity/ai/behavior/PoiCompetitorScan.java -index 8ec07578c1e41997a2e5ef158885ad3f4c2a31b6..6dcacfca6eb4a8a6425f1aaeb57733d29989032a 100644 +index 8ec07578c1e41997a2e5ef158885ad3f4c2a31b6..003d85261bc0df871a8247c193e2b45c822b66b3 100644 --- a/src/main/java/net/minecraft/world/entity/ai/behavior/PoiCompetitorScan.java +++ b/src/main/java/net/minecraft/world/entity/ai/behavior/PoiCompetitorScan.java -@@ -17,6 +17,12 @@ public class PoiCompetitorScan { +@@ -17,6 +17,11 @@ public class PoiCompetitorScan { return context.group(context.present(MemoryModuleType.JOB_SITE), context.present(MemoryModuleType.NEAREST_LIVING_ENTITIES)).apply(context, (jobSite, mobs) -> { return (world, entity, time) -> { GlobalPos globalPos = context.get(jobSite); + // Folia start - region threading + if (globalPos.dimension() != world.dimension() || !io.papermc.paper.util.TickThread.isTickThreadFor(world, globalPos.pos())) { -+ entity.getBrain().eraseMemory(MemoryModuleType.JOB_SITE); + return true; + } + // Folia end - region threading