public function getContents() { return $this->slots; }
/** * 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; }