Beispiel #1
0
 /**
  * @param int             $index
  * @param Player|Player[] $target
  */
 public function sendArmorSlot($index, $target)
 {
     if ($target instanceof Player) {
         $target = [$target];
     }
     $armor = $this->getArmorContents();
     $slots = [];
     foreach ($armor as $i => $slot) {
         if ($slot->getId() === Item::AIR) {
             $slots[$i] = 255;
         } else {
             $slots[$i] = $slot->getId();
         }
     }
     $pk = new PlayerArmorEquipmentPacket();
     $pk->eid = $this->getHolder()->getId();
     $pk->slots = $slots;
     $pk->encode();
     $pk->isEncoded = true;
     foreach ($target as $player) {
         if ($player === $this->getHolder()) {
             /** @var Player $player */
             //$pk2 = clone $pk;
             //$pk2->eid = 0;
             $pk2 = new ContainerSetSlotPacket();
             $pk2->windowid = 0x78;
             //Armor window id constant
             $pk2->slot = $index;
             $pk2->item = $this->getItem($index);
             $player->dataPacket($pk2);
         } else {
             $player->dataPacket($pk);
         }
     }
 }
 /**
  * @param int             $index
  * @param Player|Player[] $target
  */
 public function sendArmorSlot($index, $target)
 {
     if ($target instanceof Player) {
         $target = [$target];
     }
     $armor = $this->getArmorContents();
     $slots = [];
     foreach ($armor as $i => $slot) {
         if ($slot->getId() === Item::AIR) {
             $slots[$i] = 255;
         } else {
             $slots[$i] = $slot->getId();
         }
     }
     $pk = new PlayerArmorEquipmentPacket();
     $pk->eid = $this->getHolder()->getId();
     $pk->slots = $slots;
     $pk->encode();
     $pk->isEncoded = true;
     foreach ($target as $player) {
         if ($player === $this->getHolder()) {
             /** @var Player $player */
             $pk2 = new ContainerSetSlotPacket();
             $pk2->windowid = ContainerSetContentPacket::SPECIAL_ARMOR;
             $pk2->slot = $index - $this->getSize();
             $pk2->item = $this->getItem($index);
             $player->dataPacket($pk2);
         } else {
             $player->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING));
         }
     }
 }
Beispiel #3
0
 /**
  * Send NPC Players
  *
  * @param StatueModel $statue        	
  * @param Player $player        	
  * @internal param unknown $modId
  * @internal param Player $p
  */
 public function spawnStatue(StatueModel $statue, Player $player)
 {
     $slots = [];
     $slots[0] = $statue->armorHelmet;
     $slots[1] = $statue->armorChestplate;
     $slots[2] = $statue->armorLegging;
     $slots[3] = $statue->armorBoots;
     // $eid = rand ( 101, 9900 );
     $pk = new AddPlayerPacket();
     $pk->clientID = rand(101, 9999);
     $pk->username = $statue->displayName;
     $pk->eid = $statue->eid;
     $pk->x = $statue->position->x + 0.5;
     $pk->y = $statue->position->y;
     $pk->z = $statue->position->z + 0.5;
     $pk->yaw = 0;
     $pk->pitch = 0;
     $pk->unknown1 = 0;
     $pk->unknown2 = 0;
     $pk->item = $statue->itemOnHand;
     $pk->meta = 0;
     $pk->metadata = [];
     $pk->skin = $player->getSkinData();
     $pk->encode();
     $player->dataPacket($pk);
     Server::broadcastPacket($player->getViewers(), $pk);
     $player->addEntityMotion($statue->eid, 64, 290, 0);
     if ($slots != null) {
         $pk = new PlayerArmorEquipmentPacket();
         $pk->eid = $statue->eid;
         $pk->slots = $slots;
         $pk->encode();
         $pk->isEncoded = true;
         $player->dataPacket($pk);
         Server::broadcastPacket($player->getViewers(), $pk);
     }
 }