コード例 #1
0
 public function spawnTo(Player $player)
 {
     if (isset($this->hasSpawned[$player->getLoaderId()]) or !isset($player->usedChunks[Level::chunkHash($this->chunk->getX(), $this->chunk->getZ())])) {
         return;
     }
     if (!$this->dummyReceiver instanceof DummyReceiver) {
         return;
     }
     $pk = new AddPlayerPacket();
     $pk->uuid = $this->dummyReceiver->randomUUID;
     $pk->username = $this->dummyReceiver->getName();
     $pk->eid = $this->getId();
     $pk->x = $this->x;
     $pk->y = $this->y;
     $pk->z = $this->z;
     $pk->speedX = $this->motionX;
     $pk->speedY = $this->motionY;
     $pk->speedZ = $this->motionZ;
     $pk->yaw = $this->yaw;
     $pk->pitch = $this->pitch;
     $pk->item = Item::get(Item::DIAMOND_PICKAXE);
     $pk->metadata = $this->dummyReceiver->getDataProperties();
     $player->dataPacket($pk);
     $this->dummyReceiver->getInventory()->sendArmorContents($player);
     if (!$this instanceof Player) {
         $this->server->removePlayerListData($this->dummyReceiver->randomUUID, [$player]);
     }
     $this->hasSpawned[$player->getLoaderId()] = $player;
 }
コード例 #2
0
 /**
  * 더미 이벤트 수신 세션을 생성합니다.
  *
  * @param string $username        	
  * @param string $address        	
  * @param number $port        	
  * @return DummyReceiver
  */
 public function openSession($username, $address = "DUMMYPLAYER", $port = 0)
 {
     $player = new DummyReceiver($this, null, $address, $port);
     $player->setName($username);
     $player->setDisplayName($username);
     $player->setNameTagVisible(true);
     $player->setNameTag($username);
     $player->setSkin($this->skin, "dummy");
     $player->doInit();
     $this->sessions->attach($player, $username);
     $this->ackStore[$username] = [];
     $this->replyStore[$username] = [];
     $this->server->addPlayer($username, $player);
     $this->server->addOnlinePlayer($player);
     return $player;
 }