public function refillChest(Chest $chest, $refillPair = true) { $replaceSlots = []; $chest->clearAll(); if (count($replaceSlots) >= $chest->getSize() / 2) { array_slice($replaceSlots, $chest->getSize() / 2 - 1); } foreach ($replaceSlots as $slot) { $item = null; // TODO: Decide items to put in chest. $chest->setItem($slot, $item); } if ($chest->isPaired() && $refillPair) { // Large chests $this->refillChest($chest->getPair(), false); } }