diff --git a/src/pocketmine/inventory/ShapedRecipe.php b/src/pocketmine/inventory/ShapedRecipe.php index 8e4b746cb..c3909c0d8 100644 --- a/src/pocketmine/inventory/ShapedRecipe.php +++ b/src/pocketmine/inventory/ShapedRecipe.php @@ -202,11 +202,10 @@ class ShapedRecipe implements CraftingRecipe{ /** * @param Item[][] $input - * @param Item[][] $output * * @return bool */ - public function matchItems(array $input, array $output) : bool{ + private function matchInputMap(array $input) : bool{ $map = $this->getIngredientMap(); //match the given items to the requested items @@ -223,12 +222,8 @@ class ShapedRecipe implements CraftingRecipe{ } } - //we shouldn't need to check if there's anything left in the map, the last block should take care of that - //however, we DO need to check if there are too many items in the grid outside of the recipe - - /** - * @var Item[] $row - */ + //check if there are any items left in the grid outside of the recipe + /** @var Item[] $row */ foreach($input as $y => $row){ foreach($row as $x => $needItem){ if(!$needItem->isNull()){ @@ -237,6 +232,23 @@ class ShapedRecipe implements CraftingRecipe{ } } + return true; + } + + /** + * @param Item[][] $input + * @param Item[][] $output + * + * @return bool + */ + public function matchItems(array $input, array $output) : bool{ + if( + !$this->matchInputMap($input) and //as-is + !$this->matchInputMap(array_map(function(array $row) : array{ return array_reverse($row, false); }, $input)) //mirrored + ){ + return false; + } + //and then, finally, check that the output items are good: /** @var Item[] $haveItems */