CraftingManager: Make sort() static

this doesn't need access to $this
This commit is contained in:
Dylan K. Taylor 2018-03-29 11:45:06 +01:00
parent 08c48d8145
commit 145a4fad0f

View File

@ -144,7 +144,7 @@ class CraftingManager{
*
* @return int
*/
public function sort(Item $i1, Item $i2){
public static function sort(Item $i1, Item $i2){
if($i1->getId() > $i2->getId()){
return 1;
}elseif($i1->getId() < $i2->getId()){
@ -212,7 +212,7 @@ class CraftingManager{
*/
public function registerShapelessRecipe(ShapelessRecipe $recipe) : void{
$ingredients = $recipe->getIngredientList();
usort($ingredients, [$this, "sort"]);
usort($ingredients, [self::class, "sort"]);
$this->shapelessRecipes[json_encode($recipe->getResult())][json_encode($ingredients)] = $recipe;
$this->craftingDataCache = null;
}
@ -271,7 +271,7 @@ class CraftingManager{
if(isset($this->shapelessRecipes[$outputHash])){
$list = array_merge(...$inputMap);
usort($list, [$this, "sort"]);
usort($list, [self::class, "sort"]);
$inputHash = json_encode($list);
$recipe = $this->shapelessRecipes[$outputHash][$inputHash] ?? null;