mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-12 08:49:42 +00:00
Remove useless Recipe interface
This commit is contained in:
parent
2ef91f6e2e
commit
a9a647855b
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
*
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
@ -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
|
||||
|
@ -109,10 +109,6 @@ class ShapelessRecipe implements CraftingRecipe{
|
||||
return $count;
|
||||
}
|
||||
|
||||
public function registerToCraftingManager(CraftingManager $manager) : void{
|
||||
$manager->registerShapelessRecipe($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CraftingGrid $grid
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user