2021-06-11 12:02:28 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
|
|
|
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/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
2021-11-25 08:54:06 +00:00
|
|
|
index f9733ec478fe5aa0fa678a5f4482ab6e7045c033..851bbe0bab26f39f19aa85cb2779fb06c77f7e46 100644
|
2021-06-11 12:02:28 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
2021-11-24 16:06:46 +00:00
|
|
|
@@ -1666,6 +1666,14 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
2021-09-11 20:18:44 +00:00
|
|
|
}
|
|
|
|
// 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());
|
2021-11-24 16:06:46 +00:00
|
|
|
@@ -1678,17 +1686,22 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
2021-06-11 12:02:28 +00:00
|
|
|
BlockPos blockposition = movingobjectpositionblock.getBlockPos();
|
|
|
|
Direction enumdirection = movingobjectpositionblock.getDirection();
|
|
|
|
|
2021-09-11 20:18:44 +00:00
|
|
|
+ // Paper start - move check up and check actual location as well
|
|
|
|
+ final Vec3 clickedLocation = movingobjectpositionblock.getLocation();
|
2021-09-24 08:02:14 +00:00
|
|
|
+ if (isOutsideOfReach(blockposition.getX() + 0.5D, blockposition.getY() + 0.5D, blockposition.getZ() + 0.5D)
|
2021-09-11 20:18:44 +00:00
|
|
|
+ || !Double.isFinite(clickedLocation.x) || !Double.isFinite(clickedLocation.y) || !Double.isFinite(clickedLocation.z)
|
|
|
|
+ || isOutsideOfReach(clickedLocation.x, clickedLocation.y, clickedLocation.z)) {
|
2021-06-11 12:02:28 +00:00
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // Paper end - move check up
|
|
|
|
+
|
|
|
|
this.player.resetLastActionTime();
|
2021-06-14 09:46:59 +00:00
|
|
|
int i = this.player.level.getMaxBuildHeight();
|
|
|
|
|
|
|
|
if (blockposition.getY() < i) {
|
2021-11-24 16:06:46 +00:00
|
|
|
if (this.awaitingPositionFromClient == null && this.player.distanceToSqr((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && worldserver.mayInteract(this.player, blockposition)) {
|
2021-06-11 12:02:28 +00:00
|
|
|
// CraftBukkit start - Check if we can actually do something over this large a distance
|
2021-06-14 09:46:59 +00:00
|
|
|
- Location eyeLoc = this.getCraftPlayer().getEyeLocation();
|
2021-06-11 12:02:28 +00:00
|
|
|
- double reachDistance = NumberConversions.square(eyeLoc.getX() - blockposition.getX()) + NumberConversions.square(eyeLoc.getY() - blockposition.getY()) + NumberConversions.square(eyeLoc.getZ() - blockposition.getZ());
|
2021-06-14 09:46:59 +00:00
|
|
|
- if (reachDistance > (this.getCraftPlayer().getGameMode() == org.bukkit.GameMode.CREATIVE ? ServerGamePacketListenerImpl.CREATIVE_PLACE_DISTANCE_SQUARED : ServerGamePacketListenerImpl.SURVIVAL_PLACE_DISTANCE_SQUARED)) {
|
2021-06-11 12:02:28 +00:00
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
+ // Paper - move check up
|
|
|
|
this.player.stopUsingItem(); // SPIGOT-4706
|
|
|
|
// CraftBukkit end
|
|
|
|
InteractionResult enuminteractionresult = this.player.gameMode.useItemOn(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock);
|