public function teleport(Vector3 $pos, $yaw = null, $pitch = null)
{
if ($pos instanceof Location) {
$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);
$this->server->getPluginManager()->callEvent($ev = new EntityTeleportEvent($this, $from, $to));
if ($ev->isCancelled()) {
return false;
}
$this->ySize = 0;
$pos = $ev->getTo();
$this->setMotion($this->temporalVector->setComponents(0, 0, 0));
if ($this->setPositionAndRotation($pos, $yaw === null ? $this->yaw : $yaw, $pitch === null ? $this->pitch : $pitch) !== false) {
$this->resetFallDistance();
$this->onGround = true;
$this->lastX = $this->x;
$this->lastY = $this->y;
$this->lastZ = $this->z;
$this->lastYaw = $this->yaw;
$this->lastPitch = $this->pitch;
$this->updateMovement();
return true;
}
return false;
}