Change last X/Y/Z/Yaw/Pitch on teleport

This commit is contained in:
Shoghi Cervantes 2014-11-30 12:49:35 +01:00
parent e44ed4da3b
commit 1963d8fde0

View File

@ -1175,8 +1175,8 @@ abstract class Entity extends Location implements Metadatable{
*/
public function teleport(Vector3 $pos, $yaw = null, $pitch = null){
if($pos instanceof Location){
$yaw = $pos->yaw;
$pitch = $pos->pitch;
$yaw = $yaw === null ? $pos->yaw : $yaw;
$pitch = $pitch === null ? $pos->pitch : $pitch;
}
$from = Position::fromObject($this, $this->level);
$to = Position::fromObject($pos, $pos instanceof Position ? $pos->getLevel() : $this->level);
@ -1192,6 +1192,17 @@ abstract class Entity extends Location implements Metadatable{
$this->fallDistance = 0;
$this->onGround = true;
$this->lastX = $this->x;
$this->lastY = $this->y;
$this->lastZ = $this->z;
$this->lastYaw = $this->yaw;
$this->lastPitch = $this->pitch;
foreach($this->hasSpawned as $player){
$player->addEntityMovement($this->getId(), $this->x, $this->y, $this->z, $this->yaw, $this->pitch);
}
return true;
}