diff --git a/src/pocketmine/crafting/FurnaceRecipe.php b/src/pocketmine/crafting/FurnaceRecipe.php index 2fa65a477..cc1a4bf6e 100644 --- a/src/pocketmine/crafting/FurnaceRecipe.php +++ b/src/pocketmine/crafting/FurnaceRecipe.php @@ -42,13 +42,6 @@ class FurnaceRecipe{ $this->ingredient = clone $ingredient; } - /** - * @param Item $item - */ - public function setInput(Item $item) : void{ - $this->ingredient = clone $item; - } - /** * @return Item */ diff --git a/src/pocketmine/crafting/ShapedRecipe.php b/src/pocketmine/crafting/ShapedRecipe.php index 6f48b3cfe..9c6be8f49 100644 --- a/src/pocketmine/crafting/ShapedRecipe.php +++ b/src/pocketmine/crafting/ShapedRecipe.php @@ -88,7 +88,11 @@ class ShapedRecipe implements CraftingRecipe{ $this->shape = $shape; foreach($ingredients as $char => $i){ - $this->setIngredient($char, $i); + if(strpos(implode($this->shape), $char) === false){ + throw new \InvalidArgumentException("Symbol '$char' does not appear in the recipe shape"); + } + + $this->ingredientList[$char] = clone $i; } $this->results = array_map(function(Item $item) : Item{ return clone $item; }, $results); @@ -118,23 +122,6 @@ class ShapedRecipe implements CraftingRecipe{ return $this->getResults(); } - /** - * @param string $key - * @param Item $item - * - * @return $this - * @throws \InvalidArgumentException - */ - public function setIngredient(string $key, Item $item){ - if(strpos(implode($this->shape), $key) === false){ - throw new \InvalidArgumentException("Symbol '$key' does not appear in the recipe shape"); - } - - $this->ingredientList[$key] = clone $item; - - return $this; - } - /** * @return Item[][] */ diff --git a/src/pocketmine/crafting/ShapelessRecipe.php b/src/pocketmine/crafting/ShapelessRecipe.php index 9cecfdf1f..4bf7d2af0 100644 --- a/src/pocketmine/crafting/ShapelessRecipe.php +++ b/src/pocketmine/crafting/ShapelessRecipe.php @@ -40,7 +40,13 @@ class ShapelessRecipe implements CraftingRecipe{ public function __construct(array $ingredients, array $results){ foreach($ingredients as $item){ //Ensure they get split up properly - $this->addIngredient($item); + if(count($this->ingredients) + $item->getCount() > 9){ + throw new \InvalidArgumentException("Shapeless recipes cannot have more than 9 ingredients"); + } + + while($item->getCount() > 0){ + $this->ingredients[] = $item->pop(); + } } $this->results = array_map(function(Item $item) : Item{ return clone $item; }, $results); @@ -54,44 +60,6 @@ class ShapelessRecipe implements CraftingRecipe{ return $this->getResults(); } - /** - * @param Item $item - * - * @return ShapelessRecipe - * - * @throws \InvalidArgumentException - */ - public function addIngredient(Item $item) : ShapelessRecipe{ - if(count($this->ingredients) + $item->getCount() > 9){ - throw new \InvalidArgumentException("Shapeless recipes cannot have more than 9 ingredients"); - } - - while($item->getCount() > 0){ - $this->ingredients[] = $item->pop(); - } - - return $this; - } - - /** - * @param Item $item - * - * @return $this - */ - public function removeIngredient(Item $item){ - foreach($this->ingredients as $index => $ingredient){ - if($item->getCount() <= 0){ - break; - } - if($ingredient->equals($item, !$item->hasAnyDamageValue(), $item->hasNamedTag())){ - unset($this->ingredients[$index]); - $item->pop(); - } - } - - return $this; - } - /** * @return Item[] */