From a9a647855b7097a3f0756cb904e13f08a5b02766 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 25 Nov 2018 17:08:09 +0000 Subject: [PATCH] Remove useless Recipe interface --- src/pocketmine/inventory/CraftingManager.php | 13 ++------- src/pocketmine/inventory/CraftingRecipe.php | 2 +- src/pocketmine/inventory/FurnaceRecipe.php | 6 +--- src/pocketmine/inventory/Recipe.php | 29 -------------------- src/pocketmine/inventory/ShapedRecipe.php | 4 --- src/pocketmine/inventory/ShapelessRecipe.php | 4 --- 6 files changed, 5 insertions(+), 53 deletions(-) delete mode 100644 src/pocketmine/inventory/Recipe.php diff --git a/src/pocketmine/inventory/CraftingManager.php b/src/pocketmine/inventory/CraftingManager.php index b378af8ef..f8aa119c4 100644 --- a/src/pocketmine/inventory/CraftingManager.php +++ b/src/pocketmine/inventory/CraftingManager.php @@ -52,13 +52,13 @@ class CraftingManager{ foreach($recipes as $recipe){ switch($recipe["type"]){ case 0: - $this->registerRecipe(new ShapelessRecipe( + $this->registerShapelessRecipe(new ShapelessRecipe( array_map(function(array $data) : Item{ return Item::jsonDeserialize($data); }, $recipe["input"]), array_map(function(array $data) : Item{ return Item::jsonDeserialize($data); }, $recipe["output"]) )); break; case 1: - $this->registerRecipe(new ShapedRecipe( + $this->registerShapedRecipe(new ShapedRecipe( $recipe["shape"], array_map(function(array $data) : Item{ return Item::jsonDeserialize($data); }, $recipe["input"]), array_map(function(array $data) : Item{ return Item::jsonDeserialize($data); }, $recipe["output"]) @@ -68,7 +68,7 @@ class CraftingManager{ case 3: $result = $recipe["output"]; $resultItem = Item::jsonDeserialize($result); - $this->registerRecipe(new FurnaceRecipe($resultItem, ItemFactory::get($recipe["inputId"], $recipe["inputDamage"] ?? -1, 1))); + $this->registerFurnaceRecipe(new FurnaceRecipe($resultItem, ItemFactory::get($recipe["inputId"], $recipe["inputDamage"] ?? -1, 1))); break; default: break; @@ -282,11 +282,4 @@ class CraftingManager{ public function matchFurnaceRecipe(Item $input) : ?FurnaceRecipe{ return $this->furnaceRecipes[$input->getId() . ":" . $input->getDamage()] ?? $this->furnaceRecipes[$input->getId() . ":?"] ?? null; } - - /** - * @param Recipe $recipe - */ - public function registerRecipe(Recipe $recipe) : void{ - $recipe->registerToCraftingManager($this); - } } diff --git a/src/pocketmine/inventory/CraftingRecipe.php b/src/pocketmine/inventory/CraftingRecipe.php index df37ca6e6..1ea9d71e7 100644 --- a/src/pocketmine/inventory/CraftingRecipe.php +++ b/src/pocketmine/inventory/CraftingRecipe.php @@ -25,7 +25,7 @@ namespace pocketmine\inventory; use pocketmine\item\Item; -interface CraftingRecipe extends Recipe{ +interface CraftingRecipe{ /** * Returns a list of items needed to craft this recipe. This MUST NOT include Air items or items with a zero count. * diff --git a/src/pocketmine/inventory/FurnaceRecipe.php b/src/pocketmine/inventory/FurnaceRecipe.php index c8ed4be61..bcd333f8a 100644 --- a/src/pocketmine/inventory/FurnaceRecipe.php +++ b/src/pocketmine/inventory/FurnaceRecipe.php @@ -25,7 +25,7 @@ namespace pocketmine\inventory; use pocketmine\item\Item; -class FurnaceRecipe implements Recipe{ +class FurnaceRecipe{ /** @var Item */ private $output; @@ -62,8 +62,4 @@ class FurnaceRecipe implements Recipe{ public function getResult() : Item{ return clone $this->output; } - - public function registerToCraftingManager(CraftingManager $manager) : void{ - $manager->registerFurnaceRecipe($this); - } } diff --git a/src/pocketmine/inventory/Recipe.php b/src/pocketmine/inventory/Recipe.php deleted file mode 100644 index 883eea6d9..000000000 --- a/src/pocketmine/inventory/Recipe.php +++ /dev/null @@ -1,29 +0,0 @@ -shape; } - public function registerToCraftingManager(CraftingManager $manager) : void{ - $manager->registerShapedRecipe($this); - } - /** * @param CraftingGrid $grid * @param bool $reverse diff --git a/src/pocketmine/inventory/ShapelessRecipe.php b/src/pocketmine/inventory/ShapelessRecipe.php index 7db3d3c13..01fd17d72 100644 --- a/src/pocketmine/inventory/ShapelessRecipe.php +++ b/src/pocketmine/inventory/ShapelessRecipe.php @@ -109,10 +109,6 @@ class ShapelessRecipe implements CraftingRecipe{ return $count; } - public function registerToCraftingManager(CraftingManager $manager) : void{ - $manager->registerShapelessRecipe($this); - } - /** * @param CraftingGrid $grid *