diff --git a/src/crafting/CraftingGrid.php b/src/crafting/CraftingGrid.php index eb3ea5f25..b72392016 100644 --- a/src/crafting/CraftingGrid.php +++ b/src/crafting/CraftingGrid.php @@ -96,7 +96,7 @@ abstract class CraftingGrid extends SimpleInventory{ * Returns the item at offset x,y, offset by where the starts of the recipe rectangle are. */ public function getIngredient(int $x, int $y) : Item{ - if($this->startX !== null and $this->startY !== null){ + if($this->startX !== null && $this->startY !== null){ return $this->getItem(($y + $this->startY) * $this->gridWidth + ($x + $this->startX)); } diff --git a/src/crafting/ShapedRecipe.php b/src/crafting/ShapedRecipe.php index 5fc881a97..fc02224a9 100644 --- a/src/crafting/ShapedRecipe.php +++ b/src/crafting/ShapedRecipe.php @@ -62,14 +62,14 @@ class ShapedRecipe implements CraftingRecipe{ */ public function __construct(array $shape, array $ingredients, array $results){ $this->height = count($shape); - if($this->height > 3 or $this->height <= 0){ + if($this->height > 3 || $this->height <= 0){ throw new \InvalidArgumentException("Shaped recipes may only have 1, 2 or 3 rows, not $this->height"); } $shape = array_values($shape); $this->width = strlen($shape[0]); - if($this->width > 3 or $this->width <= 0){ + if($this->width > 3 || $this->width <= 0){ throw new \InvalidArgumentException("Shaped recipes may only have 1, 2 or 3 columns, not $this->width"); } @@ -79,7 +79,7 @@ class ShapedRecipe implements CraftingRecipe{ } for($x = 0; $x < $this->width; ++$x){ - if($row[$x] !== ' ' and !isset($ingredients[$row[$x]])){ + if($row[$x] !== ' ' && !isset($ingredients[$row[$x]])){ throw new \InvalidArgumentException("No item specified for symbol '" . $row[$x] . "'"); } } @@ -172,7 +172,7 @@ class ShapedRecipe implements CraftingRecipe{ $given = $grid->getIngredient($reverse ? $this->width - $x - 1 : $x, $y); $required = $this->getIngredient($x, $y); - if(!$required->equals($given, !$required->hasAnyDamageValue(), $required->hasNamedTag()) or $required->getCount() > $given->getCount()){ + if(!$required->equals($given, !$required->hasAnyDamageValue(), $required->hasNamedTag()) || $required->getCount() > $given->getCount()){ return false; } } @@ -182,10 +182,10 @@ class ShapedRecipe implements CraftingRecipe{ } public function matchesCraftingGrid(CraftingGrid $grid) : bool{ - if($this->width !== $grid->getRecipeWidth() or $this->height !== $grid->getRecipeHeight()){ + if($this->width !== $grid->getRecipeWidth() || $this->height !== $grid->getRecipeHeight()){ return false; } - return $this->matchInputMap($grid, false) or $this->matchInputMap($grid, true); + return $this->matchInputMap($grid, false) || $this->matchInputMap($grid, true); } } diff --git a/src/crafting/ShapelessRecipe.php b/src/crafting/ShapelessRecipe.php index 195b917fa..4ef3bfc1a 100644 --- a/src/crafting/ShapelessRecipe.php +++ b/src/crafting/ShapelessRecipe.php @@ -85,7 +85,7 @@ class ShapelessRecipe implements CraftingRecipe{ foreach($this->ingredients as $needItem){ foreach($input as $j => $haveItem){ - if($haveItem->equals($needItem, !$needItem->hasAnyDamageValue(), $needItem->hasNamedTag()) and $haveItem->getCount() >= $needItem->getCount()){ + if($haveItem->equals($needItem, !$needItem->hasAnyDamageValue(), $needItem->hasNamedTag()) && $haveItem->getCount() >= $needItem->getCount()){ unset($input[$j]); continue 2; }