pocketmine\inventory\ShapedRecipe::__construct PHP Method

__construct() public method

public __construct ( Item $result, variadic $shape )
$result pocketmine\item\Item
$shape variadic
    public function __construct(Item $result, ...$shape)
    {
        if (count($shape) === 0) {
            throw new \InvalidArgumentException("Must provide a shape");
        }
        if (count($shape) > 3) {
            throw new \InvalidStateException("Crafting recipes should be 1, 2, 3 rows, not " . count($shape));
        }
        foreach ($shape as $y => $row) {
            if (strlen($row) === 0 or strlen($row) > 3) {
                throw new \InvalidStateException("Crafting rows should be 1, 2, 3 characters, not " . count($row));
            }
            $this->ingredients[] = array_fill(0, strlen($row), null);
            $len = strlen($row);
            for ($i = 0; $i < $len; ++$i) {
                $this->shape[$row[$i]] = null;
                if (!isset($this->shapeItems[$row[$i]])) {
                    $this->shapeItems[$row[$i]] = [new Vector2($i, $y)];
                } else {
                    $this->shapeItems[$row[$i]][] = new Vector2($i, $y);
                }
            }
        }
        $this->output = clone $result;
    }