Added Player->teleportImmediate() for tp force

This commit is contained in:
Shoghi Cervantes 2015-05-12 00:21:02 +02:00
parent aa38a4885f
commit 9791071262
No known key found for this signature in database
GPG Key ID: 78464DB0A7837F89

View File

@ -2931,8 +2931,8 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
}
public function sendPosition(Vector3 $pos, $yaw = null, $pitch = null, $mode = 0, $channel = Network::CHANNEL_PRIORITY){
$yaw = $yaw === null ? $pos->yaw : $yaw;
$pitch = $pitch === null ? $pos->pitch : $pitch;
$yaw = $yaw === null ? $this->yaw : $yaw;
$pitch = $pitch === null ? $this->pitch : $pitch;
$pk = new MovePlayerPacket();
$pk->eid = $this->getId();
@ -2994,6 +2994,35 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
}
}
/**
* This method may not be reliable. Clients don't like to be moved into unloaded chunks.
* Use teleport() for a delayed teleport after chunks have been sent.
*
* @param Vector3 $pos
* @param float $yaw
* @param float $pitch
*/
public function teleportImmediate(Vector3 $pos, $yaw = null, $pitch = null){
if(parent::teleport($pos, $yaw, $pitch)){
foreach($this->windowIndex as $window){
if($window === $this->inventory){
continue;
}
$this->removeWindow($window);
}
$this->forceMovement = new Vector3($this->x, $this->y, $this->z);
$this->sendPosition($this, $this->yaw, $this->pitch, 1, Network::CHANNEL_WORLD_EVENTS);
$this->resetFallDistance();
$this->orderChunks();
$this->nextChunkOrderRun = 0;
$this->newPosition = null;
}
}
/**
* @param Inventory $inventory