setItem() public method

This method should not be used by plugins, use the Inventory
public setItem ( integer $index, Item $item ) : boolean
$index integer
$item pocketmine\item\Item
return boolean
Example #1
0
 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);
     }
 }