|
| 1 | +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
| 2 | +From: PureGero <puregero@gmail.com> |
| 3 | +Date: Mon, 26 Jan 2026 00:21:28 +0900 |
| 4 | +Subject: [PATCH] Make max interaction range configurable (PaperMC/Paper#11164) |
| 5 | + The server validates incoming interaction packets by ensuring the player |
| 6 | + sending them is inside their interaction range. For this, the server adds a |
| 7 | + magic value, by default 1.0, to the original interaction range to account for |
| 8 | + latency issues. |
| 9 | + |
| 10 | +This value however may be too low in high latency environments. |
| 11 | +The patch exposes a new configuration option to configure said value. |
| 12 | + |
| 13 | +ShreddedPaper: Backported from Paper 1.21 |
| 14 | + |
| 15 | +diff --git a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java |
| 16 | +index 0467ad99b144aa81a04baa45d4c8bbb2b70185a2..e943c561a7c92244129417de9ef9feb61b005630 100644 |
| 17 | +--- a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java |
| 18 | ++++ b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java |
| 19 | +@@ -3,6 +3,7 @@ package io.papermc.paper.configuration; |
| 20 | + import co.aikar.timings.MinecraftTimings; |
| 21 | + import com.mojang.logging.LogUtils; |
| 22 | + import io.papermc.paper.configuration.constraint.Constraints; |
| 23 | ++import io.papermc.paper.configuration.type.number.DoubleOr; |
| 24 | + import io.papermc.paper.configuration.type.number.IntOr; |
| 25 | + import net.kyori.adventure.text.Component; |
| 26 | + import net.kyori.adventure.text.format.NamedTextColor; |
| 27 | +@@ -336,6 +337,8 @@ public class GlobalConfiguration extends ConfigurationPart { |
| 28 | + public boolean useDimensionTypeForCustomSpawners = false; |
| 29 | + public boolean strictAdvancementDimensionCheck = false; |
| 30 | + public IntOr.Default compressionLevel = IntOr.Default.USE_DEFAULT; |
| 31 | ++ @Comment("Defines the leniency distance added on the server to the interaction range of a player when validating interact packets.") |
| 32 | ++ public DoubleOr.Default clientInteractionLeniencyDistance = DoubleOr.Default.USE_DEFAULT; |
| 33 | + } |
| 34 | + |
| 35 | + public BlockUpdates blockUpdates; |
| 36 | +diff --git a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java |
| 37 | +index 83a726bcf8b7dce73a361b0d79dbd63a0afc7a12..783eac6e458c6f1a0584301fb84a2fe341868f34 100644 |
| 38 | +--- a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java |
| 39 | ++++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java |
| 40 | +@@ -193,6 +193,7 @@ public class PaperConfigurations extends Configurations<GlobalConfiguration, Wor |
| 41 | + .serializers(builder -> builder |
| 42 | + .register(new PacketClassSerializer()) |
| 43 | + .register(IntOr.Default.SERIALIZER) |
| 44 | ++ .register(DoubleOr.Default.SERIALIZER) |
| 45 | + ); |
| 46 | + } |
| 47 | + |
| 48 | +diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java |
| 49 | +index 28b85349908829ddbe90718e4c5729a36952847f..cd75648913ec747e8b3471c6d11eea913c992536 100644 |
| 50 | +--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java |
| 51 | ++++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java |
| 52 | +@@ -2850,7 +2850,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl |
| 53 | + |
| 54 | + AABB axisalignedbb = entity.getBoundingBox(); |
| 55 | + |
| 56 | +- if (this.player.canInteractWithEntity(axisalignedbb, 1.0D)) { |
| 57 | ++ if (this.player.canInteractWithEntity(axisalignedbb, io.papermc.paper.configuration.GlobalConfiguration.get().misc.clientInteractionLeniencyDistance.or(1.0D))) { // Paper - configurable lenience value for interact range // ShreddedPaper - backported |
| 58 | + if (entity instanceof Mob mob) mob.ticksSinceLastInteraction = 0; // Purpur |
| 59 | + packet.dispatch(new ServerboundInteractPacket.Handler() { |
| 60 | + private void performInteraction(InteractionHand enumhand, ServerGamePacketListenerImpl.EntityInteraction playerconnection_a, PlayerInteractEntityEvent event) { // CraftBukkit |
0 commit comments