From 45ffc2bf1af34fa06217ab93e771b003f1a7ed79 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Wed, 15 Jul 2020 19:38:53 -0700 Subject: [PATCH] Move range check for block placing up (#3917) Co-authored-by: Spottedleaf --- ...ove-range-check-for-block-placing-up.patch | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Spigot-Server-Patches/0544-Move-range-check-for-block-placing-up.patch diff --git a/Spigot-Server-Patches/0544-Move-range-check-for-block-placing-up.patch b/Spigot-Server-Patches/0544-Move-range-check-for-block-placing-up.patch new file mode 100644 index 000000000..5b8d63da5 --- /dev/null +++ b/Spigot-Server-Patches/0544-Move-range-check-for-block-placing-up.patch @@ -0,0 +1,35 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Spottedleaf +Date: Wed, 15 Jul 2020 19:34:11 -0700 +Subject: [PATCH] Move range check for block placing up + + +diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java +index cf83059fec9f11df992827f0c0249243caa9ac33..95d57c6de95eca580ca4e3183db851e5a15de342 100644 +--- a/src/main/java/net/minecraft/server/PlayerConnection.java ++++ b/src/main/java/net/minecraft/server/PlayerConnection.java +@@ -1435,15 +1435,19 @@ public class PlayerConnection implements PacketListenerPlayIn { + BlockPosition blockposition = movingobjectpositionblock.getBlockPosition(); + EnumDirection enumdirection = movingobjectpositionblock.getDirection(); + ++ // Paper start - move check up ++ Location eyeLoc = this.getPlayer().getEyeLocation(); ++ double reachDistance = NumberConversions.square(eyeLoc.getX() - blockposition.getX()) + NumberConversions.square(eyeLoc.getY() - blockposition.getY()) + NumberConversions.square(eyeLoc.getZ() - blockposition.getZ()); ++ if (reachDistance > (this.getPlayer().getGameMode() == org.bukkit.GameMode.CREATIVE ? CREATIVE_PLACE_DISTANCE_SQUARED : SURVIVAL_PLACE_DISTANCE_SQUARED)) { ++ return; ++ } ++ // Paper end - move check up ++ + this.player.resetIdleTimer(); + if (blockposition.getY() < this.minecraftServer.getMaxBuildHeight()) { + if (this.teleportPos == null && this.player.g((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && worldserver.a((EntityHuman) this.player, blockposition)) { + // CraftBukkit start - Check if we can actually do something over this large a distance +- Location eyeLoc = this.getPlayer().getEyeLocation(); +- double reachDistance = NumberConversions.square(eyeLoc.getX() - blockposition.getX()) + NumberConversions.square(eyeLoc.getY() - blockposition.getY()) + NumberConversions.square(eyeLoc.getZ() - blockposition.getZ()); +- if (reachDistance > (this.getPlayer().getGameMode() == org.bukkit.GameMode.CREATIVE ? CREATIVE_PLACE_DISTANCE_SQUARED : SURVIVAL_PLACE_DISTANCE_SQUARED)) { +- return; +- } ++ // Paper - move check up + this.player.clearActiveItem(); // SPIGOT-4706 + // CraftBukkit end + EnumInteractionResult enuminteractionresult = this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock);