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 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->putLShort(strlen($nbt)); $this->put($nbt); }
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->buffer .= \pack("n", 0); return; } $this->buffer .= \pack("n", $item->getId()); $this->buffer .= \chr($item->getCount()); $this->buffer .= \pack("n", $item->getDamage() === \null ? -1 : $item->getDamage()); $nbt = $item->getCompoundTag(); $this->buffer .= \pack("n", \strlen($nbt)); $this->buffer .= $nbt; }
protected function putSlot(Item $item) { if ($item->getID() === 0) { $this->putShort(-1); } else { $this->putShort($item->getID()); $this->putByte($item->getCount()); $this->putShort($item->getDamage()); $nbt = $item->getCompoundTag(); $this->putByte(strlen($nbt)); $this->put($nbt); } }
public function putSlot(Item $item) { if ($item->getId() === 0) { $this->putVarInt(0); return; } $this->putVarInt($item->getId()); $auxValue = ($item->getDamage() ?? -1) << 8 | $item->getCount(); $this->putVarInt($auxValue); $nbt = $item->getCompoundTag(); $this->putLShort(strlen($nbt)); $this->put($nbt); }