mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-16 00:15:35 +00:00
CraftingManager: Make sort() static
this doesn't need access to $this
This commit is contained in:
parent
08c48d8145
commit
145a4fad0f
@ -144,7 +144,7 @@ class CraftingManager{
|
|||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function sort(Item $i1, Item $i2){
|
public static function sort(Item $i1, Item $i2){
|
||||||
if($i1->getId() > $i2->getId()){
|
if($i1->getId() > $i2->getId()){
|
||||||
return 1;
|
return 1;
|
||||||
}elseif($i1->getId() < $i2->getId()){
|
}elseif($i1->getId() < $i2->getId()){
|
||||||
@ -212,7 +212,7 @@ class CraftingManager{
|
|||||||
*/
|
*/
|
||||||
public function registerShapelessRecipe(ShapelessRecipe $recipe) : void{
|
public function registerShapelessRecipe(ShapelessRecipe $recipe) : void{
|
||||||
$ingredients = $recipe->getIngredientList();
|
$ingredients = $recipe->getIngredientList();
|
||||||
usort($ingredients, [$this, "sort"]);
|
usort($ingredients, [self::class, "sort"]);
|
||||||
$this->shapelessRecipes[json_encode($recipe->getResult())][json_encode($ingredients)] = $recipe;
|
$this->shapelessRecipes[json_encode($recipe->getResult())][json_encode($ingredients)] = $recipe;
|
||||||
$this->craftingDataCache = null;
|
$this->craftingDataCache = null;
|
||||||
}
|
}
|
||||||
@ -271,7 +271,7 @@ class CraftingManager{
|
|||||||
|
|
||||||
if(isset($this->shapelessRecipes[$outputHash])){
|
if(isset($this->shapelessRecipes[$outputHash])){
|
||||||
$list = array_merge(...$inputMap);
|
$list = array_merge(...$inputMap);
|
||||||
usort($list, [$this, "sort"]);
|
usort($list, [self::class, "sort"]);
|
||||||
|
|
||||||
$inputHash = json_encode($list);
|
$inputHash = json_encode($list);
|
||||||
$recipe = $this->shapelessRecipes[$outputHash][$inputHash] ?? null;
|
$recipe = $this->shapelessRecipes[$outputHash][$inputHash] ?? null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user