pocketmine\inventory\ShapedRecipe::getIngredient PHP Method

getIngredient() public method

public getIngredient ( $x, $y ) : null | Item
$x
$y
return null | pocketmine\item\Item
    public function getIngredient($x, $y)
    {
        return isset($this->ingredients[$y][$x]) ? $this->ingredients[$y][$x] : Item::get(Item::AIR);
    }

Usage Example

 private static function writeShapedRecipe(ShapedRecipe $recipe, BinaryStream $stream)
 {
     $stream->putInt($recipe->getWidth());
     $stream->putInt($recipe->getHeight());
     for ($z = 0; $z < $recipe->getHeight(); ++$z) {
         for ($x = 0; $x < $recipe->getWidth(); ++$x) {
             $stream->putSlot($recipe->getIngredient($x, $z));
         }
     }
     $stream->putInt(1);
     $stream->putSlot($recipe->getResult());
     $stream->putUUID($recipe->getId());
     return CraftingDataPacket::ENTRY_SHAPED;
 }