From ef515cc6f5fbcfee65f934d15fa19d83704c9550 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Wed, 8 Mar 2023 19:44:01 -0800 Subject: [PATCH] Consider non-owned chunks in entity movement as unloaded This should prevent entities from moving into areas not owned by the current region. --- patches/server/0004-Threaded-Regions.patch | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/patches/server/0004-Threaded-Regions.patch b/patches/server/0004-Threaded-Regions.patch index aedeb35..c9d9353 100644 --- a/patches/server/0004-Threaded-Regions.patch +++ b/patches/server/0004-Threaded-Regions.patch @@ -9600,6 +9600,23 @@ index e08f4e39db4ee3fed62e37364d17dcc5c5683504..03d239460a2e856c1f59d6bcd95811c8 + // Folia end - region threading } } +diff --git a/src/main/java/io/papermc/paper/util/CollisionUtil.java b/src/main/java/io/papermc/paper/util/CollisionUtil.java +index a87f6380b2c387fb0cdd40d5087b5c93492e3c88..77d369ca6be814d1f5a19ec37b44800529e6cda3 100644 +--- a/src/main/java/io/papermc/paper/util/CollisionUtil.java ++++ b/src/main/java/io/papermc/paper/util/CollisionUtil.java +@@ -480,7 +480,12 @@ public final class CollisionUtil { + if (chunkProvider == null) { + chunk = (ChunkAccess)getter.getChunkForCollisions(currChunkX, currChunkZ); + } else { ++ // Folia start - ignore chunk if we do not own the region ++ if (!io.papermc.paper.util.TickThread.isTickThreadFor(chunkProvider.chunkMap.level, currChunkX, currChunkZ)) { ++ chunk = null; ++ } else { // Folia end - ignore chunk if we do not own the region + chunk = loadChunks ? chunkProvider.getChunk(currChunkX, currChunkZ, true) : chunkProvider.getChunkAtIfLoadedImmediately(currChunkX, currChunkZ); ++ } // Folia - ignore chunk if we do not own the region + } + + if (chunk == null) { diff --git a/src/main/java/io/papermc/paper/util/CoordinateUtils.java b/src/main/java/io/papermc/paper/util/CoordinateUtils.java index 413e4b6da027876dbbe8eb78f2568a440f431547..3a7dbcb9964723b8ed5e6b0a1ee4267923c746e4 100644 --- a/src/main/java/io/papermc/paper/util/CoordinateUtils.java