public getIngredientMap ( ) : |
||
return |
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;
}
/** * @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; }