diff options
author | Raphfrk <raphfrk@gmail.com> | 2011-03-07 23:06:50 +0000 |
---|---|---|
committer | Erik Broes <erikbroes@grum.nl> | 2011-03-23 19:31:30 +0100 |
commit | 94646027206951fa23c92c3a06e0e90a612f01dc (patch) | |
tree | 525771e0d945663e42323b4664839109789a92f2 /src/main/java/net/minecraft/server/NetServerHandler.java | |
parent | fdcf1c3c3aa81f9524ef1534c3fe1142b290530e (diff) | |
download | craftbukkit-94646027206951fa23c92c3a06e0e90a612f01dc.tar craftbukkit-94646027206951fa23c92c3a06e0e90a612f01dc.tar.gz craftbukkit-94646027206951fa23c92c3a06e0e90a612f01dc.tar.lz craftbukkit-94646027206951fa23c92c3a06e0e90a612f01dc.tar.xz craftbukkit-94646027206951fa23c92c3a06e0e90a612f01dc.zip |
Update to PlayerMoveEvent. The From field is set the value of the previous To Field, and, Pitch or Yaw changes of more then 10 degrees will trigger the event
Diffstat (limited to 'src/main/java/net/minecraft/server/NetServerHandler.java')
-rw-r--r-- | src/main/java/net/minecraft/server/NetServerHandler.java | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/main/java/net/minecraft/server/NetServerHandler.java b/src/main/java/net/minecraft/server/NetServerHandler.java index 048a223f..35b8a621 100644 --- a/src/main/java/net/minecraft/server/NetServerHandler.java +++ b/src/main/java/net/minecraft/server/NetServerHandler.java @@ -52,9 +52,11 @@ public class NetServerHandler extends NetHandler implements ICommandListener { private final CraftServer server; // Get position of last block hit for BlockDamageLevel.STOPPED - private double lastPosX = Double.MIN_VALUE; - private double lastPosY = Double.MIN_VALUE; - private double lastPosZ = Double.MIN_VALUE; + private double lastPosX = Double.MAX_VALUE; + private double lastPosY = Double.MAX_VALUE; + private double lastPosZ = Double.MAX_VALUE; + private float lastPitch = Float.MAX_VALUE; + private float lastYaw = Float.MAX_VALUE; // Store the last block right clicked and what type it was private CraftBlock lastRightClicked; @@ -110,12 +112,14 @@ public class NetServerHandler extends NetHandler implements ICommandListener { // CraftBukkit start Player player = getPlayer(); - Location from = new Location(player.getWorld(), i, j, k, this.e.yaw, this.e.pitch); + Location from = new Location(player.getWorld(), lastPosX, lastPosY, lastPosZ, lastYaw, lastPitch); Location to = player.getLocation(); // Prevent 40 event-calls for less than a single pixel of movement >.> double delta = Math.pow( this.lastPosX - this.i, 2) + Math.pow( this.lastPosY - this.j, 2) + Math.pow( this.lastPosZ - this.k, 2); - if (delta > 1f/256) { + float deltaAngle = Math.abs(this.lastYaw - this.e.yaw) + Math.abs(this.lastPitch - this.e.pitch); + + if (delta > 1f/256 || deltaAngle > 10f) { PlayerMoveEvent event = new PlayerMoveEvent(Type.PLAYER_MOVE, player, from, to); server.getPluginManager().callEvent(event); @@ -131,6 +135,8 @@ public class NetServerHandler extends NetHandler implements ICommandListener { this.lastPosX = this.e.locX; this.lastPosY = this.e.locY; this.lastPosZ = this.e.locZ; + this.lastYaw = this.e.yaw; + this.lastPitch = this.e.pitch; } // CraftBukkit end |