From eb90c777f32c8398c9df6cb81650105f6241e042 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Pueyo Date: Wed, 20 Mar 2013 18:32:47 +0100 Subject: [PATCH] Better Teleportation --- src/Player.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Player.php b/src/Player.php index 88a4634c13..25977d05cc 100644 --- a/src/Player.php +++ b/src/Player.php @@ -478,19 +478,21 @@ class Player{ )); } - public function teleport(Vector3 $pos){ + public function teleport(Vector3 $pos, $yaw = 0, $pitch = 0){ if($this->entity instanceof Entity){ $this->entity->fallY = false; $this->entity->fallStart = false; - $this->entity->setPosition($pos->x, $pos->y, $pos->z, 0, 0); + $this->entity->setPosition($pos->x, $pos->y, $pos->z, $yaw, $pitch); + $this->entity->calculateVelocity(); + $this->entity->updateLast(); } $this->dataPacket(MC_MOVE_PLAYER, array( "eid" => 0, "x" => $pos->x, "y" => $pos->y, "z" => $pos->z, - "yaw" => 0, - "pitch" => 0, + "yaw" => $yaw, + "pitch" => $pitch, )); }