private function handle(TaskHandler $handler) { if ($handler->isDelayed()) { $nextRun = $this->currentTick + $handler->getDelay(); } else { $nextRun = $this->currentTick; } $handler->setNextRun($nextRun); $this->tasks[$handler->getTaskId()] = $handler; $this->queue->insert($handler, $nextRun); return $handler; }
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); } }