public function setItem($index, Item $item)
{
$i = $this->getSlotIndex($index);
$d = NBT::putItemHelper($item, $index);
if ($item->getId() === Item::AIR or $item->getCount() <= 0) {
if ($i >= 0) {
unset($this->namedtag->Items[$i]);
}
} elseif ($i < 0) {
for ($i = 0; $i <= $this->getSize(); ++$i) {
if (!isset($this->namedtag->Items[$i])) {
break;
}
}
$this->namedtag->Items[$i] = $d;
} else {
$this->namedtag->Items[$i] = $d;
}
return true;
}