22declare(strict_types=1);
37 protected \SplFixedArray $slots;
39 public function __construct(
int $size){
40 $this->slots = new \SplFixedArray($size);
41 parent::__construct();
52 return $this->slots[$index] !== null ? clone $this->slots[$index] :
VanillaItems::AIR();
55 protected function internalSetItem(
int $index,
Item $item) : void{
56 $this->slots[$index] = $item->isNull() ? null : $item;
63 public function getContents(
bool $includeEmpty =
false) : array{
66 foreach($this->slots as $i => $slot){
68 $contents[$i] = clone $slot;
69 }elseif($includeEmpty){
70 $contents[$i] = VanillaItems::AIR();
78 for($i = 0, $size = $this->getSize(); $i < $size; ++$i){
79 if(!isset($items[$i]) || $items[$i]->isNull()){
80 $this->slots[$i] =
null;
82 $this->slots[$i] = clone $items[$i];
88 $slotItem = $this->slots[$slot];
89 return $slotItem !==
null && $slotItem->equals($test,
true, $checkTags) ? $slotItem->getCount() : 0;
93 return $this->slots[$index] === null || $this->slots[$index]->isNull();
internalSetContents(array $items)
getContents(bool $includeEmpty=false)
getMatchingItemCount(int $slot, Item $test, bool $checkTags)