Inheritance: extends ContainerInventory
Esempio n. 1
0
 public function saveNBT()
 {
     $this->namedtag->Items = new Enum("Items", []);
     $this->namedtag->Items->setTagType(NBT::TAG_Compound);
     for ($index = 0; $index < $this->getSize(); ++$index) {
         $this->setItem($index, $this->inventory->getItem($index));
     }
 }
 /**
  * @param Item[] $items
  */
 public function setContents(array $items)
 {
     if (count($items) > $this->size) {
         $items = array_slice($items, 0, $this->size, true);
     }
     parent::setContents($items);
     $leftItems = array_slice($items, 0, $this->left->getSize(), true);
     $this->left->setContents($leftItems);
     if (count($items) > $this->left->getSize()) {
         $rightItems = array_slice($items, $this->left->getSize() - 1, $this->right->getSize(), true);
         $this->right->setContents($rightItems);
     }
 }
 public function onClose(Player $who)
 {
     if (count($this->getViewers()) === 1) {
         $pk = new BlockEventPacket();
         $pk->x = $this->right->getHolder()->getX();
         $pk->y = $this->right->getHolder()->getY();
         $pk->z = $this->right->getHolder()->getZ();
         $pk->case1 = 1;
         $pk->case2 = 0;
         if (($level = $this->right->getHolder()->getLevel()) instanceof Level) {
             $level->addChunkPacket($this->right->getHolder()->getX() >> 4, $this->right->getHolder()->getZ() >> 4, $pk);
         }
     }
     parent::onClose($who);
 }
 public function onClose(Player $who)
 {
     if (\count($this->getViewers()) === 1) {
         $pk = new TileEventPacket();
         $pk->x = $this->right->getHolder()->getX();
         $pk->y = $this->right->getHolder()->getY();
         $pk->z = $this->right->getHolder()->getZ();
         $pk->case1 = 1;
         $pk->case2 = 0;
         if (($level = $this->right->getHolder()->getLevel()) instanceof Level) {
             Server::broadcastPacket($level->getUsingChunk($this->right->getHolder()->getX() >> 4, $this->right->getHolder()->getZ() >> 4), $pk->setChannel(Network::CHANNEL_WORLD_EVENTS));
         }
     }
     parent::onClose($who);
 }