public final function equals(Item $item, $checkDamage = true, $checkCompound = true) { return $this->id === $item->getId() and ($checkDamage === false or $this->getDamage() === $item->getDamage()) and ($checkCompound === false or $this->getCompoundTag() === $item->getCompoundTag()); }
public function first(Item $item) { $count = max(1, $item->getCount()); $checkDamage = $item->getDamage() === null ? false : true; $checkTags = $item->getCompoundTag() === null ? false : true; foreach ($this->getContents() as $index => $i) { if ($item->equals($i, $checkDamage, $checkTags) and $i->getCount() >= $count) { return $index; } } return -1; }
public function putSlot(Item $item) { if ($item->getId() === 0) { $this->putShort(0); return; } $this->putShort($item->getId()); $this->putByte($item->getCount()); $this->putShort($item->getDamage() === null ? -1 : $item->getDamage()); $nbt = $item->getCompoundTag(); $this->putShort(strlen($nbt)); $this->put($nbt); }