pocketmine\inventory\ShapedRecipe::getIngredientMap PHP Method

getIngredientMap() public method

public getIngredientMap ( ) : Item[][]
return pocketmine\item\Item[][]
    public function getIngredientMap()
    {
        $ingredients = [];
        foreach ($this->ingredients as $y => $row) {
            $ingredients[$y] = [];
            foreach ($row as $x => $ingredient) {
                if ($ingredient !== null) {
                    $ingredients[$y][$x] = clone $ingredient;
                } else {
                    $ingredients[$y][$x] = Item::get(Item::AIR);
                }
            }
        }
        return $ingredients;
    }

Usage Example

 /**
  * @param ShapedRecipe $recipe
  */
 public function registerShapedRecipe(ShapedRecipe $recipe)
 {
     $result = $recipe->getResult();
     $this->recipes[$recipe->getId()->toBinary()] = $recipe;
     $ingredients = $recipe->getIngredientMap();
     $hash = "";
     foreach ($ingredients as $v) {
         foreach ($v as $item) {
             if ($item !== null) {
                 /** @var Item $item */
                 $hash .= $item->getId() . ":" . ($item->getDamage() === null ? "?" : $item->getDamage()) . "x" . $item->getCount() . ",";
             }
         }
         $hash .= ";";
     }
     $this->recipeLookup[$result->getId() . ":" . $result->getDamage()][$hash] = $recipe;
 }