Player: fixed PlayerMoveEvent->getFrom() returning unexpected results on movement reversion

fixes #4043
This commit is contained in:
Dylan K. Taylor 2021-02-26 00:30:32 +00:00
parent fac2bd3379
commit 78f9985377
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -1653,13 +1653,6 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
$deltaAngle = abs($this->lastYaw - $to->yaw) + abs($this->lastPitch - $to->pitch);
if($delta > 0.0001 or $deltaAngle > 1.0){
$this->lastX = $to->x;
$this->lastY = $to->y;
$this->lastZ = $to->z;
$this->lastYaw = $to->yaw;
$this->lastPitch = $to->pitch;
$ev = new PlayerMoveEvent($this, $from, $to);
$ev->call();
@ -1674,6 +1667,12 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
return;
}
$this->lastX = $to->x;
$this->lastY = $to->y;
$this->lastZ = $to->z;
$this->lastYaw = $to->yaw;
$this->lastPitch = $to->pitch;
$this->broadcastMovement();
$distance = sqrt((($from->x - $to->x) ** 2) + (($from->z - $to->z) ** 2));
@ -1696,13 +1695,6 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
}
protected function revertMovement(Location $from) : void{
$this->lastX = $from->x;
$this->lastY = $from->y;
$this->lastZ = $from->z;
$this->lastYaw = $from->yaw;
$this->lastPitch = $from->pitch;
$this->setPosition($from);
$this->sendPosition($from, $from->yaw, $from->pitch, MovePlayerPacket::MODE_RESET);
}