Наследование: extends TemporaryInventory
Пример #1
0
 public function onUpdate()
 {
     if ($this->getLevel()->getServer()->getTick() % 20 == 0) {
         //Update per second
         $item = $this->inventory->getItem(0);
         if (!isset($this->item) or !$item->deepEquals($this->item)) {
             $this->item = $item;
             $enchantmentList = new EnchantmentList(3);
             for ($i = 0; $i < 3; $i++) {
                 $enchantmentList->setSlot($i, new EnchantmentEntry([Enchantment::getEnchantment(mt_rand(0, 24))], 1, "Test"));
             }
             $pk = new CraftingDataPacket();
             $pk->entries = [$enchantmentList];
             foreach ($this->getInventory()->getViewers() as $player) {
                 $windowId = $player->getWindowId($this->getInventory());
                 if ($windowId > 0) {
                     $player->dataPacket($pk);
                 }
             }
         }
     }
     return true;
 }