/**
  * 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);
         $this->resetFallDistance();
         $this->orderChunks();
         $this->nextChunkOrderRun = 0;
         $this->newPosition = null;
     }
 }
Exemple #2
0
 public function teleport(Vector3 $pos, $yaw = null, $pitch = null)
 {
     if (!$this->isOnline()) {
         return;
     }
     $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;
     }
 }
Exemple #3
0
 public function teleport(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->airTicks = 300;
         $this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, 300);
         $pk = new MovePlayerPacket();
         $pk->eid = $this->getId();
         $pk->x = $this->x;
         $pk->y = $this->y + $this->getEyeHeight();
         $pk->z = $this->z;
         $pk->bodyYaw = 0;
         $pk->pitch = $this->pitch;
         $pk->yaw = $this->yaw;
         $pk->mode = 1;
         $pk->teleport = 1;
         $this->directDataPacket($pk);
         $this->resetFallDistance();
         $this->orderChunks();
         $this->nextChunkOrderRun = 0;
         $this->forceMovement = new Vector3($this->x, $this->y, $this->z);
         $this->newPosition = null;
     }
 }
Exemple #4
0
 public function teleport(Vector3 $pos, $yaw = null, $pitch = null)
 {
     if (parent::teleport($pos, $yaw, $pitch)) {
         $this->airTicks = 300;
         $this->fallDistance = 0;
         $this->orderChunks();
         $this->chunkLoadTask->setNextRun(0);
         $this->forceMovement = $pos;
         $pk = new MovePlayerPacket();
         $pk->eid = 0;
         $pk->x = $this->x;
         $pk->y = $this->y + $this->getEyeHeight();
         $pk->z = $this->z;
         $pk->bodyYaw = $this->yaw;
         $pk->pitch = $this->pitch;
         $pk->yaw = $this->yaw;
         $pk->teleport = true;
         $this->directDataPacket($pk);
     }
 }