mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-02 17:32:03 +01:00
Improve interact distance check (#6591)
This commit is contained in:
parent
0d34a95f8f
commit
325ba14ca5
1 changed files with 20 additions and 4 deletions
|
@ -8,14 +8,30 @@ diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListener
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
|
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||||
|
}
|
||||||
|
// Spigot end
|
||||||
|
|
||||||
|
+ // Paper start
|
||||||
|
+ private boolean isOutsideOfReach(double x, double y, double z) {
|
||||||
|
+ Location eyeLoc = this.getCraftPlayer().getEyeLocation();
|
||||||
|
+ double reachDistance = NumberConversions.square(eyeLoc.getX() - x) + NumberConversions.square(eyeLoc.getY() - y) + NumberConversions.square(eyeLoc.getZ() - z);
|
||||||
|
+ return reachDistance > (this.getCraftPlayer().getGameMode() == org.bukkit.GameMode.CREATIVE ? CREATIVE_PLACE_DISTANCE_SQUARED : SURVIVAL_PLACE_DISTANCE_SQUARED);
|
||||||
|
+ }
|
||||||
|
+ // Paper end
|
||||||
|
+
|
||||||
|
@Override
|
||||||
|
public void handleUseItemOn(ServerboundUseItemOnPacket packet) {
|
||||||
|
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
|
||||||
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||||
BlockPos blockposition = movingobjectpositionblock.getBlockPos();
|
BlockPos blockposition = movingobjectpositionblock.getBlockPos();
|
||||||
Direction enumdirection = movingobjectpositionblock.getDirection();
|
Direction enumdirection = movingobjectpositionblock.getDirection();
|
||||||
|
|
||||||
+ // Paper start - move check up
|
+ // Paper start - move check up and check actual location as well
|
||||||
+ Location eyeLoc = this.getCraftPlayer().getEyeLocation();
|
+ final Vec3 clickedLocation = movingobjectpositionblock.getLocation();
|
||||||
+ double reachDistance = NumberConversions.square(eyeLoc.getX() - blockposition.getX()) + NumberConversions.square(eyeLoc.getY() - blockposition.getY()) + NumberConversions.square(eyeLoc.getZ() - blockposition.getZ());
|
+ if (isOutsideOfReach(blockposition.getX(), blockposition.getY(), blockposition.getZ())
|
||||||
+ if (reachDistance > (this.getCraftPlayer().getGameMode() == org.bukkit.GameMode.CREATIVE ? CREATIVE_PLACE_DISTANCE_SQUARED : SURVIVAL_PLACE_DISTANCE_SQUARED)) {
|
+ || !Double.isFinite(clickedLocation.x) || !Double.isFinite(clickedLocation.y) || !Double.isFinite(clickedLocation.z)
|
||||||
|
+ || isOutsideOfReach(clickedLocation.x, clickedLocation.y, clickedLocation.z)) {
|
||||||
+ return;
|
+ return;
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end - move check up
|
+ // Paper end - move check up
|
||||||
|
|
Loading…
Reference in a new issue