Remove useless Recipe interface

This commit is contained in:
Dylan K. Taylor 2018-11-25 17:08:09 +00:00
parent 2ef91f6e2e
commit a9a647855b
6 changed files with 5 additions and 53 deletions

View File

@ -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);
}
}

View File

@ -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.
*

View File

@ -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);
}
}

View File

@ -1,29 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\inventory;
interface Recipe{
public function registerToCraftingManager(CraftingManager $manager) : void;
}

View File

@ -181,10 +181,6 @@ class ShapedRecipe implements CraftingRecipe{
return $this->shape;
}
public function registerToCraftingManager(CraftingManager $manager) : void{
$manager->registerShapedRecipe($this);
}
/**
* @param CraftingGrid $grid
* @param bool $reverse

View File

@ -109,10 +109,6 @@ class ShapelessRecipe implements CraftingRecipe{
return $count;
}
public function registerToCraftingManager(CraftingManager $manager) : void{
$manager->registerShapelessRecipe($this);
}
/**
* @param CraftingGrid $grid
*