public function teleport(Vector3 $pos, $yaw = null, $pitch = null)
{
if (!$this->isOnline()) {
return false;
}
$oldPos = $this->getPosition();
if (parent::teleport($pos, $yaw, $pitch)) {
foreach ($this->windowIndex as $window) {
if ($window === $this->inventory) {
continue;
}
$this->removeWindow($window);
}
$this->teleportPosition = new Vector3($this->x, $this->y, $this->z);
if (!$this->checkTeleportPosition()) {
$this->forceMovement = $oldPos;
} else {
$this->spawnToAll();
}
$this->resetFallDistance();
$this->nextChunkOrderRun = 0;
$this->newPosition = null;
$this->stopSleep();
return true;
}
return false;
}