summaryrefslogtreecommitdiffstats
path: root/src/main/java/net
diff options
context:
space:
mode:
authorRigby <rigby@onarandombox.com>2011-06-30 06:26:18 +0100
committerEvilSeph <evilseph@unaligned.org>2011-06-30 13:42:18 -0400
commit1e209e8e11303abd42a155b48f84fb8239e4a1e7 (patch)
tree1da1ce0c6ffeab9436a4069abd96d7a82dc8f96d /src/main/java/net
parent49df44ad6c4625301b32762d059936c0aeb42d25 (diff)
downloadcraftbukkit-1e209e8e11303abd42a155b48f84fb8239e4a1e7.tar
craftbukkit-1e209e8e11303abd42a155b48f84fb8239e4a1e7.tar.gz
craftbukkit-1e209e8e11303abd42a155b48f84fb8239e4a1e7.tar.lz
craftbukkit-1e209e8e11303abd42a155b48f84fb8239e4a1e7.tar.xz
craftbukkit-1e209e8e11303abd42a155b48f84fb8239e4a1e7.zip
Improved PlayerMove event implementation.
Diffstat (limited to 'src/main/java/net')
-rw-r--r--src/main/java/net/minecraft/server/NetServerHandler.java57
1 files changed, 21 insertions, 36 deletions
diff --git a/src/main/java/net/minecraft/server/NetServerHandler.java b/src/main/java/net/minecraft/server/NetServerHandler.java
index b9877f17..34e5d0b8 100644
--- a/src/main/java/net/minecraft/server/NetServerHandler.java
+++ b/src/main/java/net/minecraft/server/NetServerHandler.java
@@ -136,8 +136,21 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
// CraftBukkit start
Player player = this.getPlayer();
- Location from = new Location(player.getWorld(), this.lastPosX, this.lastPosY, this.lastPosZ, this.lastYaw, this.lastPitch);
- Location to = player.getLocation();
+ Location from = player.getLocation().clone(); // Get the Players current location.
+ Location to = player.getLocation().clone(); // Start off the To location as the Players current location.
+
+ // If the packet contains movement information then we update the To location with the correct XYZ.
+ if (packet10flying.h && !(packet10flying.h && packet10flying.y == -999.0D && packet10flying.stance == -999.0D)) {
+ to.setX(packet10flying.x);
+ to.setY(packet10flying.y);
+ to.setZ(packet10flying.z);
+ }
+
+ // If the packet contains look information then we update the To location with the correct Yaw & Pitch.
+ if (packet10flying.hasLook) {
+ to.setYaw(packet10flying.yaw);
+ to.setPitch(packet10flying.pitch);
+ }
// Prevent 40 event-calls for less than a single pixel of movement >.>
double delta = Math.pow(this.lastPosX - this.x, 2) + Math.pow(this.lastPosY - this.y, 2) + Math.pow(this.lastPosZ - this.z, 2);
@@ -163,11 +176,11 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
return;
}
- this.player.locX = to.getX();
- this.player.locY = to.getY();
- this.player.locZ = to.getZ();
- this.player.yaw = to.getYaw();
- this.player.pitch = to.getPitch();
+ /* Check to see if the Players Location has some how changed during the call of the event.
+ This can happen due to a plugin teleporting the player instead of using .setTo() */
+ if(!from.equals(this.getPlayer().getLocation())){
+ return;
+ }
}
this.lastPosX = this.player.locX;
@@ -177,41 +190,13 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
this.lastPitch = this.player.pitch;
}
- if (Math.abs(packet10flying.x) > 32000000 || Math.abs(packet10flying.z) > 32000000) {
+ if (Double.isNaN(packet10flying.x) || Double.isNaN(packet10flying.y) || Double.isNaN(packet10flying.z) || Double.isNaN(packet10flying.stance)) {
player.teleport(player.getWorld().getSpawnLocation());
System.err.println(player.getName() + " was caught trying to crash the server with an invalid position.");
player.kickPlayer("Nope!");
return;
}
- if (Double.isNaN(packet10flying.x) || packet10flying.x == Double.POSITIVE_INFINITY || packet10flying.x == Double.NEGATIVE_INFINITY) {
- player.teleport(player.getWorld().getSpawnLocation());
- System.err.println(player.getName() + " was caught trying to set an invalid position.");
- player.kickPlayer("Nope!");
- return;
- }
-
- if (Double.isNaN(packet10flying.y) || packet10flying.y == Double.POSITIVE_INFINITY || packet10flying.y == Double.NEGATIVE_INFINITY) {
- player.teleport(player.getWorld().getSpawnLocation());
- System.err.println(player.getName() + " was caught trying to set an invalid position.");
- player.kickPlayer("Nope!");
- return;
- }
-
- if (Double.isNaN(packet10flying.z) || packet10flying.z == Double.POSITIVE_INFINITY || packet10flying.z == Double.NEGATIVE_INFINITY) {
- player.teleport(player.getWorld().getSpawnLocation());
- System.err.println(player.getName() + " was caught trying to set an invalid position.");
- player.kickPlayer("Nope!");
- return;
- }
-
- if (Double.isNaN(packet10flying.stance) || packet10flying.stance == Double.POSITIVE_INFINITY || packet10flying.stance == Double.NEGATIVE_INFINITY) {
- player.teleport(player.getWorld().getSpawnLocation());
- System.err.println(player.getName() + " was caught trying to set an invalid position.");
- player.kickPlayer("Nope!");
- return;
- }
-
if (this.checkMovement && !this.player.dead) {
// CraftBukkit end
double d1;