summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEvilSeph <evilseph@gmail.com>2013-12-20 22:46:55 -0500
committerEvilSeph <evilseph@gmail.com>2013-12-20 23:38:18 -0500
commitdfcff7eabf5937fa66b6115c866a3ad14a2cf9ce (patch)
tree2fc019c870ce533ec5d65bc6016125ef38235065 /src
parent6d9a6fbb4bfe2d1aa9c28440f7951b53573bb505 (diff)
downloadcraftbukkit-dfcff7eabf5937fa66b6115c866a3ad14a2cf9ce.tar
craftbukkit-dfcff7eabf5937fa66b6115c866a3ad14a2cf9ce.tar.gz
craftbukkit-dfcff7eabf5937fa66b6115c866a3ad14a2cf9ce.tar.lz
craftbukkit-dfcff7eabf5937fa66b6115c866a3ad14a2cf9ce.tar.xz
craftbukkit-dfcff7eabf5937fa66b6115c866a3ad14a2cf9ce.zip
Account for different reach limit in Survival/Creative. Fixes BUKKIT-4257
When we first added the reach limiter in CraftBukkit there was no difference between how far the client could reach in vanilla while in Survival or Creative. At some point in Minecraft's cycle Creative was given a block extra to work with and our protection was not updated to account for this. We need to respect the possibility of different game modes in Minecraft providing the client with varying reach distances.
Diffstat (limited to 'src')
-rw-r--r--src/main/java/net/minecraft/server/PlayerConnection.java10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index e3bd043f..29335eac 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -55,6 +55,7 @@ import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.event.player.PlayerToggleSprintEvent;
import org.bukkit.inventory.CraftingInventory;
import org.bukkit.inventory.InventoryView;
+import org.bukkit.util.NumberConversions;
// CraftBukkit end
public class PlayerConnection implements PacketPlayInListener {
@@ -94,7 +95,8 @@ public class PlayerConnection implements PacketPlayInListener {
private int lastTick = MinecraftServer.currentTick;
private int lastDropTick = MinecraftServer.currentTick;
private int dropCount = 0;
- private static final int PLACE_DISTANCE_SQUARED = 6 * 6;
+ private static final int SURVIVAL_PLACE_DISTANCE_SQUARED = 6 * 6;
+ private static final int CREATIVE_PLACE_DISTANCE_SQUARED = 7 * 7;
// Get position of last block hit for BlockDamageLevel.STOPPED
private double lastPosX = Double.MAX_VALUE;
@@ -618,7 +620,8 @@ public class PlayerConnection implements PacketPlayInListener {
} else {
// CraftBukkit start - Check if we can actually do something over this large a distance
Location eyeLoc = this.getPlayer().getEyeLocation();
- if (Math.pow(eyeLoc.getX() - i, 2) + Math.pow(eyeLoc.getY() - j, 2) + Math.pow(eyeLoc.getZ() - k, 2) > PLACE_DISTANCE_SQUARED) {
+ double reachDistance = NumberConversions.square(eyeLoc.getX() - i) + NumberConversions.square(eyeLoc.getY() - j) + NumberConversions.square(eyeLoc.getZ() - k);
+ if (reachDistance > (this.getPlayer().getGameMode() == org.bukkit.GameMode.CREATIVE ? CREATIVE_PLACE_DISTANCE_SQUARED : SURVIVAL_PLACE_DISTANCE_SQUARED)) {
return;
}
@@ -1606,8 +1609,7 @@ public class PlayerConnection implements PacketPlayInListener {
this.server.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
this.player.abilities.isFlying = packetplayinabilities.d(); // Actually set the player's flying status
- }
- else {
+ } else {
this.player.updateAbilities(); // Tell the player their ability was reverted
}
}