mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 23:38:25 +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
|
||||
--- a/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
|
||||
BlockPos blockposition = movingobjectpositionblock.getBlockPos();
|
||||
Direction enumdirection = movingobjectpositionblock.getDirection();
|
||||
|
||||
+ // Paper start - move check up
|
||||
+ Location eyeLoc = this.getCraftPlayer().getEyeLocation();
|
||||
+ double reachDistance = NumberConversions.square(eyeLoc.getX() - blockposition.getX()) + NumberConversions.square(eyeLoc.getY() - blockposition.getY()) + NumberConversions.square(eyeLoc.getZ() - blockposition.getZ());
|
||||
+ if (reachDistance > (this.getCraftPlayer().getGameMode() == org.bukkit.GameMode.CREATIVE ? CREATIVE_PLACE_DISTANCE_SQUARED : SURVIVAL_PLACE_DISTANCE_SQUARED)) {
|
||||
+ // Paper start - move check up and check actual location as well
|
||||
+ final Vec3 clickedLocation = movingobjectpositionblock.getLocation();
|
||||
+ if (isOutsideOfReach(blockposition.getX(), blockposition.getY(), blockposition.getZ())
|
||||
+ || !Double.isFinite(clickedLocation.x) || !Double.isFinite(clickedLocation.y) || !Double.isFinite(clickedLocation.z)
|
||||
+ || isOutsideOfReach(clickedLocation.x, clickedLocation.y, clickedLocation.z)) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end - move check up
|
||||
|
|
Loading…
Reference in a new issue