pocketmine\utils\BinaryStream::putSlot PHP Method

putSlot() public method

public putSlot ( Item $item )
$item pocketmine\item\Item
    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);
    }

Usage Example

 private static function writeFurnaceRecipe(FurnaceRecipe $recipe, BinaryStream $stream)
 {
     if ($recipe->getInput()->getDamage() !== 0) {
         //Data recipe
         $stream->putInt($recipe->getInput()->getId() << 16 | $recipe->getInput()->getDamage());
         $stream->putSlot($recipe->getResult());
         return CraftingDataPacket::ENTRY_FURNACE_DATA;
     } else {
         $stream->putInt($recipe->getInput()->getId());
         $stream->putSlot($recipe->getResult());
         return CraftingDataPacket::ENTRY_FURNACE;
     }
 }
All Usage Examples Of pocketmine\utils\BinaryStream::putSlot