From d2a5acba4a91f94af1f1eec6bdc451569bf8f4dd Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Sat, 11 Mar 2023 05:16:10 -0800 Subject: [PATCH] Do not allow players to interact with blocks outside of their region --- patches/server/0004-Threaded-Regions.patch | 13 +++++++++++-- patches/server/0007-Stream-mode.patch | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/patches/server/0004-Threaded-Regions.patch b/patches/server/0004-Threaded-Regions.patch index d1e157e..29d868f 100644 --- a/patches/server/0004-Threaded-Regions.patch +++ b/patches/server/0004-Threaded-Regions.patch @@ -15746,7 +15746,7 @@ index abcc3266d18f34d160eac87fdea153dce24c60b8..7cf0619883577a0f21ed75ba70ece90d Collections.shuffle( this.connections ); } diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 3472f7f9b98d6d9c9f6465872803ef17fa67486d..7bd6a7a86c10f5b0db94d4a1222310857d56111d 100644 +index 3472f7f9b98d6d9c9f6465872803ef17fa67486d..eb717d86deeebda89b5bcbbfce1755dd10420da9 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -320,10 +320,10 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic @@ -15991,10 +15991,19 @@ index 3472f7f9b98d6d9c9f6465872803ef17fa67486d..7bd6a7a86c10f5b0db94d4a122231085 case STOP_DESTROY_BLOCK: // Paper start - Don't allow digging in unloaded chunks - if (this.player.level.getChunkIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4) == null) { -+ if (!io.papermc.paper.util.TickThread.isTickThreadFor(this.player.getLevel(), blockposition) || this.player.level.getChunkIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4) == null) { // Folia - region threading - don't destroy blocks not owned ++ if (!io.papermc.paper.util.TickThread.isTickThreadFor(this.player.getLevel(), blockposition.getX() >> 4, blockposition.getZ() >> 4, 8) || this.player.level.getChunkIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4) == null) { // Folia - region threading - don't destroy blocks not owned this.player.connection.ackBlockChangesUpTo(packet.getSequence()); return; } +@@ -1943,7 +1958,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic + BlockPos blockposition = movingobjectpositionblock.getBlockPos(); + Vec3 vec3d1 = Vec3.atCenterOf(blockposition); + +- if (this.player.getEyePosition().distanceToSqr(vec3d1) <= ServerGamePacketListenerImpl.MAX_INTERACTION_DISTANCE) { ++ if (io.papermc.paper.util.TickThread.isTickThreadFor(this.player.getLevel(), blockposition.getX() >> 4, blockposition.getZ() >> 4, 8) && this.player.getEyePosition().distanceToSqr(vec3d1) <= ServerGamePacketListenerImpl.MAX_INTERACTION_DISTANCE) { // Folia - do not allow players to interact with blocks outside the current region + Vec3 vec3d2 = vec3d.subtract(vec3d1); + double d0 = 1.0000001D; + @@ -2056,7 +2071,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic Entity entity = packet.getEntity(worldserver); diff --git a/patches/server/0007-Stream-mode.patch b/patches/server/0007-Stream-mode.patch index ef10b74..0fc8b65 100644 --- a/patches/server/0007-Stream-mode.patch +++ b/patches/server/0007-Stream-mode.patch @@ -38,7 +38,7 @@ index 22f06033a731c3ba1b815842be7a9d575fa820f2..93262f2ade2e9f70377bbf9acfe1a02e PlaceCommand.register(this.dispatcher); PlaySoundCommand.register(this.dispatcher); diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 7bd6a7a86c10f5b0db94d4a1222310857d56111d..1fe4ac645f6e460d4960ebef7fb4e0025f5ae301 100644 +index eb717d86deeebda89b5bcbbfce1755dd10420da9..372b043c613d5071ad8cc1381826a40b7ae41bda 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -2222,7 +2222,8 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic