public function sendArmorContents($target) { if ($target instanceof Player) { $target = [$target]; } $armor = $this->getArmorContents(); $pk = new MobArmorEquipmentPacket(); $pk->eid = $this->getHolder()->getId(); $pk->slots = $armor; $pk->encode(); $pk->isEncoded = true; foreach ($target as $player) { if ($player === $this->getHolder()) { $pk2 = new ContainerSetContentPacket(); $pk2->windowid = ContainerSetContentPacket::SPECIAL_ARMOR; $pk2->slots = $armor; $player->dataPacket($pk2); } else { $player->dataPacket($pk); } } }
public function spawnTo(Player $player) { if ($player !== $this and !isset($this->hasSpawned[$player->getLoaderId()])) { $this->hasSpawned[$player->getLoaderId()] = $player; if (strlen($this->skin) < 64 * 32 * 4) { $this->close(); throw new \InvalidStateException((new \ReflectionClass($this))->getShortName() . " must have a valid skin set"); } if (!$this instanceof Player) { $this->server->updatePlayerListData($this->getUniqueId(), $this->getId(), $this->getName(), $this->skinId, $this->skin, [$player]); } $pk = new AddPlayerPacket(); $pk->uuid = $this->getUniqueId(); $pk->username = $this->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 = $this->getInventory()->getItemInHand(); $pk->metadata = $this->dataProperties; $player->dataPacket($pk); $this->inventory->sendArmorContents($player); if (!$this instanceof Player) { $this->server->removePlayerListData($this->getUniqueId(), [$player]); } } }