ShapedRecipe
in package
implements
CraftingRecipe
Interfaces, Classes, Traits and Enums
Table of Contents
- $height : int
- $ingredientList : array<string|int, Item>
- $results : array<string|int, Item>
- $shape : array<string|int, string>
- $width : int
- __construct() : mixed
- Constructs a ShapedRecipe instance.
- getHeight() : int
- getIngredient() : Item
- getIngredientList() : array<string|int, Item>
- Returns a list of items needed to craft this recipe. This MUST NOT include Air items or items with a zero count.
- getIngredientMap() : array<string|int, array<string|int, Item>>
- getResults() : array<string|int, Item>
- getResultsFor() : array<string|int, Item>
- Returns a list of results this recipe will produce when the inputs in the given crafting grid are consumed.
- getShape() : array<string|int, string>
- Returns an array of strings containing characters representing the recipe's shape.
- getWidth() : int
- matchesCraftingGrid() : bool
- Returns whether the given crafting grid meets the requirements to craft this recipe.
- matchInputMap() : bool
Properties
$height
private
int
$height
$ingredientList
private
array<string|int, Item>
$ingredientList
= []
char => Item map
$results
private
array<string|int, Item>
$results
= []
$shape
private
array<string|int, string>
$shape
= []
$width
private
int
$width
Methods
__construct()
Constructs a ShapedRecipe instance.
public
__construct(array<string|int, string> $shape, array<string|int, Item> $ingredients, array<string|int, Item> $results) : mixed
Parameters
- $shape : array<string|int, string>
-
Array of 1, 2, or 3 strings representing the rows of the recipe. This accepts an array of 1, 2 or 3 strings. Each string should be of the same length and must be at most 3 characters long. Each character represents a unique type of ingredient. Spaces are interpreted as air. - $ingredients : array<string|int, Item>
-
Char => Item map of items to be set into the shape. This accepts an array of Items, indexed by character. Every unique character (except space) in the shape array MUST have a corresponding item in this list. Space character is automatically treated as air. - $results : array<string|int, Item>
-
List of items that this recipe produces when crafted.
Note: Recipes do not need to be square. Do NOT add padding for empty rows/columns.
Return values
mixed —getHeight()
public
getHeight() : int
Return values
int —getIngredient()
public
getIngredient(int $x, int $y) : Item
Parameters
- $x : int
- $y : int
Return values
Item —getIngredientList()
Returns a list of items needed to craft this recipe. This MUST NOT include Air items or items with a zero count.
public
getIngredientList() : array<string|int, Item>
Return values
array<string|int, Item> —getIngredientMap()
public
getIngredientMap() : array<string|int, array<string|int, Item>>
Return values
array<string|int, array<string|int, Item>> —getResults()
public
getResults() : array<string|int, Item>
Return values
array<string|int, Item> —getResultsFor()
Returns a list of results this recipe will produce when the inputs in the given crafting grid are consumed.
public
getResultsFor(CraftingGrid $grid) : array<string|int, Item>
Parameters
- $grid : CraftingGrid
Return values
array<string|int, Item> —getShape()
Returns an array of strings containing characters representing the recipe's shape.
public
getShape() : array<string|int, string>
Return values
array<string|int, string> —getWidth()
public
getWidth() : int
Return values
int —matchesCraftingGrid()
Returns whether the given crafting grid meets the requirements to craft this recipe.
public
matchesCraftingGrid(CraftingGrid $grid) : bool
Parameters
- $grid : CraftingGrid
Return values
bool —matchInputMap()
private
matchInputMap(CraftingGrid $grid, bool $reverse) : bool
Parameters
- $grid : CraftingGrid
- $reverse : bool