From 645a677122257816e3dc77530dded6480ea52439 Mon Sep 17 00:00:00 2001 From: Newwind Date: Sat, 27 Jul 2024 13:18:16 +0100 Subject: [PATCH] Make max interaction range configurable (#11164) The server validates incoming interaction packets by ensuring the player sending them is inside their interaction range. For this, the server adds a magic value, by default 1.0, to the original interaction range to account for latency issues. This value however may be too low in high latency environments. The patch exposes a new configuration option to configure said value. --- patches/server/0005-Paper-config-files.patch | 12 ++++++--- .../0745-Configurable-chat-thread-limit.patch | 4 +-- ...ing-message-for-initial-server-start.patch | 4 +-- .../0988-Moonrise-optimisation-patches.patch | 8 +++--- ...ction-leniency-distance-configurable.patch | 26 +++++++++++++++++++ 5 files changed, 42 insertions(+), 12 deletions(-) create mode 100644 patches/server/1045-Make-interaction-leniency-distance-configurable.patch diff --git a/patches/server/0005-Paper-config-files.patch b/patches/server/0005-Paper-config-files.patch index 2e0119248d..8fa709f084 100644 --- a/patches/server/0005-Paper-config-files.patch +++ b/patches/server/0005-Paper-config-files.patch @@ -487,15 +487,16 @@ index 0000000000000000000000000000000000000000..d9502ba028a96f9cc846f9ed428bd806 +} diff --git a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java new file mode 100644 -index 0000000000000000000000000000000000000000..e8694dbb348e23efbe00df9b333b9dc012367aa2 +index 0000000000000000000000000000000000000000..e727414d784debd276dcc42aabf588d6fcbccc91 --- /dev/null +++ b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java -@@ -0,0 +1,320 @@ +@@ -0,0 +1,323 @@ +package io.papermc.paper.configuration; + +import co.aikar.timings.MinecraftTimings; +import com.mojang.logging.LogUtils; +import io.papermc.paper.configuration.constraint.Constraints; ++import io.papermc.paper.configuration.type.number.DoubleOr; +import io.papermc.paper.configuration.type.number.IntOr; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.format.NamedTextColor; @@ -800,6 +801,8 @@ index 0000000000000000000000000000000000000000..e8694dbb348e23efbe00df9b333b9dc0 + public boolean useDimensionTypeForCustomSpawners = false; + public boolean strictAdvancementDimensionCheck = false; + public IntOr.Default compressionLevel = IntOr.Default.USE_DEFAULT; ++ @Comment("Defines the leniency distance added on the server to the interaction range of a player when validating interact packets.") ++ public DoubleOr.Default clientInteractionLeniencyDistance = DoubleOr.Default.USE_DEFAULT; + } + + public BlockUpdates blockUpdates; @@ -851,10 +854,10 @@ index 0000000000000000000000000000000000000000..69add4a7f1147015806bc9b63a8340d1 +} diff --git a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java new file mode 100644 -index 0000000000000000000000000000000000000000..83a726bcf8b7dce73a361b0d79dbd63a0afc7a12 +index 0000000000000000000000000000000000000000..783eac6e458c6f1a0584301fb84a2fe341868f34 --- /dev/null +++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java -@@ -0,0 +1,465 @@ +@@ -0,0 +1,466 @@ +package io.papermc.paper.configuration; + +import com.google.common.base.Suppliers; @@ -1050,6 +1053,7 @@ index 0000000000000000000000000000000000000000..83a726bcf8b7dce73a361b0d79dbd63a + .serializers(builder -> builder + .register(new PacketClassSerializer()) + .register(IntOr.Default.SERIALIZER) ++ .register(DoubleOr.Default.SERIALIZER) + ); + } + diff --git a/patches/server/0745-Configurable-chat-thread-limit.patch b/patches/server/0745-Configurable-chat-thread-limit.patch index 181e263646..8b31661dd0 100644 --- a/patches/server/0745-Configurable-chat-thread-limit.patch +++ b/patches/server/0745-Configurable-chat-thread-limit.patch @@ -22,10 +22,10 @@ is actually processed, this is honestly really just exposed for the misnomers or who just wanna ensure that this won't grow over a specific size if chat gets stupidly active diff --git a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java -index e8694dbb348e23efbe00df9b333b9dc012367aa2..5a101cb6dc7f266ddc20688121ebe2403e9145f1 100644 +index e727414d784debd276dcc42aabf588d6fcbccc91..b2031483a327e22116e2584b278c3f0d59bf90a6 100644 --- a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java +++ b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java -@@ -294,7 +294,18 @@ public class GlobalConfiguration extends ConfigurationPart { +@@ -295,7 +295,18 @@ public class GlobalConfiguration extends ConfigurationPart { @PostProcess private void postProcess() { diff --git a/patches/server/0943-Add-onboarding-message-for-initial-server-start.patch b/patches/server/0943-Add-onboarding-message-for-initial-server-start.patch index ed4f8105fc..88c251c845 100644 --- a/patches/server/0943-Add-onboarding-message-for-initial-server-start.patch +++ b/patches/server/0943-Add-onboarding-message-for-initial-server-start.patch @@ -17,10 +17,10 @@ index d9502ba028a96f9cc846f9ed428bd8066b857ca3..87e5f614ba988547a827486740db217e node = loader.load(); this.verifyGlobalConfigVersion(node); diff --git a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java -index 701196635f9c08d62d785fa1b448313937259c76..5160dc617cc5037cd3f10479454159f2a9984169 100644 +index b2031483a327e22116e2584b278c3f0d59bf90a6..9db431ddb43e94d5e8dc3875d8d9c6fa5a05bbea 100644 --- a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java +++ b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java -@@ -25,6 +25,7 @@ public class GlobalConfiguration extends ConfigurationPart { +@@ -26,6 +26,7 @@ public class GlobalConfiguration extends ConfigurationPart { private static final Logger LOGGER = LogUtils.getLogger(); static final int CURRENT_VERSION = 29; // (when you change the version, change the comment, so it conflicts on rebases): private static GlobalConfiguration instance; diff --git a/patches/server/0988-Moonrise-optimisation-patches.patch b/patches/server/0988-Moonrise-optimisation-patches.patch index bfe19f4fa1..77fb393179 100644 --- a/patches/server/0988-Moonrise-optimisation-patches.patch +++ b/patches/server/0988-Moonrise-optimisation-patches.patch @@ -22226,10 +22226,10 @@ index 0000000000000000000000000000000000000000..85950a1aa732ab8c01ad28bec9e0de14 + } +} diff --git a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java -index 8a05be0d203404e8d06d9a80de2e35e473f7f936..d20969e18984c9b93483477f31b079686977b1db 100644 +index 9db431ddb43e94d5e8dc3875d8d9c6fa5a05bbea..214ea75502d4abf9ebbc99a3811e4d2f8465227e 100644 --- a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java +++ b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java -@@ -29,6 +29,45 @@ public class GlobalConfiguration extends ConfigurationPart { +@@ -30,6 +30,45 @@ public class GlobalConfiguration extends ConfigurationPart { public static GlobalConfiguration get() { return instance; } @@ -22275,7 +22275,7 @@ index 8a05be0d203404e8d06d9a80de2e35e473f7f936..d20969e18984c9b93483477f31b07968 static void set(GlobalConfiguration instance) { GlobalConfiguration.instance = instance; } -@@ -137,21 +176,6 @@ public class GlobalConfiguration extends ConfigurationPart { +@@ -138,21 +177,6 @@ public class GlobalConfiguration extends ConfigurationPart { public int incomingPacketThreshold = 300; } @@ -22297,7 +22297,7 @@ index 8a05be0d203404e8d06d9a80de2e35e473f7f936..d20969e18984c9b93483477f31b07968 public UnsupportedSettings unsupportedSettings; public class UnsupportedSettings extends ConfigurationPart { -@@ -210,7 +234,7 @@ public class GlobalConfiguration extends ConfigurationPart { +@@ -211,7 +235,7 @@ public class GlobalConfiguration extends ConfigurationPart { @PostProcess private void postProcess() { diff --git a/patches/server/1045-Make-interaction-leniency-distance-configurable.patch b/patches/server/1045-Make-interaction-leniency-distance-configurable.patch new file mode 100644 index 0000000000..341e13affd --- /dev/null +++ b/patches/server/1045-Make-interaction-leniency-distance-configurable.patch @@ -0,0 +1,26 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Newwind +Date: Thu, 25 Jul 2024 13:00:37 +0200 +Subject: [PATCH] Make interaction leniency distance configurable + +The server validates incoming interaction packets by ensuring the player +sending them is inside their interaction range. For this, the server adds +a magic value, by default 1.0, to the original interaction range to +account for latency issues. + +This value however may be too low in high latency environments. +The patch exposes a new configuration option to configure said value. + +diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +index 7796e191747be545e744564a2b0b65790f69114d..624b80c796e9c95040d71d1595d11f98e2899cf3 100644 +--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java ++++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +@@ -2703,7 +2703,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl + + AABB axisalignedbb = entity.getBoundingBox(); + +- if (this.player.canInteractWithEntity(axisalignedbb, 1.0D)) { ++ if (this.player.canInteractWithEntity(axisalignedbb, io.papermc.paper.configuration.GlobalConfiguration.get().misc.clientInteractionLeniencyDistance.or(1.0D))) { // Paper - configurable lenience value for interact range + packet.dispatch(new ServerboundInteractPacket.Handler() { + private void performInteraction(InteractionHand enumhand, ServerGamePacketListenerImpl.EntityInteraction playerconnection_a, PlayerInteractEntityEvent event) { // CraftBukkit + ItemStack itemstack = ServerGamePacketListenerImpl.this.player.getItemInHand(enumhand);