/** * @param Player|Player[] $target */ public function sendContents($target) { if ($target instanceof Player) { $target = [$target]; } $pk = new ContainerSetContentPacket(); $pk->slots = []; $holder = $this->getHolder(); if ($holder instanceof Player and $holder->isCreative()) { // mwvent - return because this packet causes problems - TODO: why? return; //TODO: Remove this workaround because of broken client foreach (Item::getCreativeItems() as $i => $item) { $pk->slots[$i] = Item::getCreativeItem($i); } } else { for ($i = 0; $i < $this->getSize(); ++$i) { //Do not send armor by error here $pk->slots[$i] = $this->getItem($i); } } foreach ($target as $player) { $pk->hotbar = []; if ($player === $this->getHolder()) { for ($i = 0; $i < $this->getHotbarSize(); ++$i) { $index = $this->getHotbarSlotIndex($i); $pk->hotbar[] = $index <= -1 ? -1 : $index + 9; } } if (($id = $player->getWindowId($this)) === -1 or $player->spawned !== true) { $this->close($player); continue; } $pk->windowid = $id; $player->dataPacket(clone $pk); } }