Inheritance: implements pocketmine\inventory\Inventory
 public function __construct(Chest $left, Chest $right)
 {
     $this->left = $left->getRealInventory();
     $this->right = $right->getRealInventory();
     $items = array_merge($this->left->getContents(), $this->right->getContents());
     BaseInventory::__construct($this, InventoryType::get(InventoryType::DOUBLE_CHEST), $items);
 }
 public function onClose(Player $who)
 {
     $pk = new ContainerClosePacket();
     $pk->windowid = $who->getWindowId($this);
     $who->dataPacket($pk);
     parent::onClose($who);
 }
 public function onClose(Player $who)
 {
     $pk = new ContainerClosePacket();
     $pk->windowid = $who->getWindowId($this);
     $who->dataPacket($pk->setChannel(Network::CHANNEL_WORLD_EVENTS));
     parent::onClose($who);
 }
Ejemplo n.º 4
0
 /**
  * @return Human
  */
 public function getHolder()
 {
     return parent::getHolder();
 }
Ejemplo n.º 5
0
 public function __construct(Chest $left, Chest $right)
 {
     $this->left = $left->getRealInventory();
     $this->right = $right->getRealInventory();
     BaseInventory::__construct($this, InventoryType::get(InventoryType::DOUBLE_CHEST));
 }
Ejemplo n.º 6
0
 /**
  * Condense items into blocks in an inventory, default MCPE item calculations (recipes) are used.
  *
  * @param BaseInventory $inv
  * @param Item|null $target
  * @return bool
  */
 public function condenseItems(BaseInventory $inv, $target = null)
 {
     // TODO: Fix inventory clear...
     $items = $target === null ? $inv->getContents() : $inv->all($target);
     if ($target !== null && !$this->canBeCondensed($target)) {
         return false;
     }
     $replace = Item::get(0);
     // First step: Merge target items...
     foreach ($items as $slot => $item) {
         if (!isset($this->condenseShapes[0][$item->getId()]) && !isset($this->condenseShapes[1][$item->getId()])) {
             continue;
         }
         $sub = $inv->all($item);
         foreach ($sub as $index => $i) {
             /** @var Item $i */
             if ($slot !== $index) {
                 $item->setCount($item->getCount() + $i->getCount());
                 $items[$index] = $replace;
                 var_dump($index . " - " . $slot);
             }
         }
     }
     $inv->setContents($items);
     // Second step: Condense items...
     foreach ($items as $slot => $item) {
         $condense = $this->condenseRecipes($item);
         if ($condense === null) {
             continue;
         }
         $cSlot = $slot;
         if ($item->getCount() > 0) {
             $cSlot = $inv->firstEmpty();
             $inv->setItem($slot, $item);
         }
         $inv->setItem($cSlot, $condense);
     }
     return true;
 }