holder = $holder; parent::__construct(); } public function getHolder() : Living{ return $this->holder; } public function getName() : string{ return "Armor"; } public function getDefaultSize() : int{ return 4; } public function getHelmet() : Item{ return $this->getItem(self::SLOT_HEAD); } public function getChestplate() : Item{ return $this->getItem(self::SLOT_CHEST); } public function getLeggings() : Item{ return $this->getItem(self::SLOT_LEGS); } public function getBoots() : Item{ return $this->getItem(self::SLOT_FEET); } public function setHelmet(Item $helmet) : bool{ return $this->setItem(self::SLOT_HEAD, $helmet); } public function setChestplate(Item $chestplate) : bool{ return $this->setItem(self::SLOT_CHEST, $chestplate); } public function setLeggings(Item $leggings) : bool{ return $this->setItem(self::SLOT_LEGS, $leggings); } public function setBoots(Item $boots) : bool{ return $this->setItem(self::SLOT_FEET, $boots); } public function sendSlot(int $index, $target) : void{ if($target instanceof Player){ $target = [$target]; } $armor = $this->getContents(true); $pk = new MobArmorEquipmentPacket(); $pk->entityRuntimeId = $this->getHolder()->getId(); $pk->slots = $armor; $pk->encode(); foreach($target as $player){ if($player === $this->getHolder()){ /** @var Player $player */ $pk2 = new InventorySlotPacket(); $pk2->windowId = $player->getWindowId($this); $pk2->inventorySlot = $index; $pk2->item = $this->getItem($index); $player->dataPacket($pk2); }else{ $player->dataPacket($pk); } } } public function sendContents($target) : void{ if($target instanceof Player){ $target = [$target]; } $armor = $this->getContents(true); $pk = new MobArmorEquipmentPacket(); $pk->entityRuntimeId = $this->getHolder()->getId(); $pk->slots = $armor; $pk->encode(); foreach($target as $player){ if($player === $this->getHolder()){ $pk2 = new InventoryContentPacket(); $pk2->windowId = $player->getWindowId($this); $pk2->items = $armor; $player->dataPacket($pk2); }else{ $player->dataPacket($pk); } } } /** * @return Player[] */ public function getViewers() : array{ return array_merge(parent::getViewers(), $this->holder->getViewers()); } }