mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-12 06:25:32 +00:00
BrewingStand: avoid duplicate method call (#4874)
This commit is contained in:
parent
f181c60209
commit
d47a7f48bd
@ -148,18 +148,20 @@ class BrewingStand extends Spawnable implements Container, Nameable{
|
|||||||
* @phpstan-return array<int, BrewingRecipe>
|
* @phpstan-return array<int, BrewingRecipe>
|
||||||
*/
|
*/
|
||||||
private function getBrewableRecipes() : array{
|
private function getBrewableRecipes() : array{
|
||||||
if($this->inventory->getItem(BrewingStandInventory::SLOT_INGREDIENT)->isNull()){
|
$ingredient = $this->inventory->getItem(BrewingStandInventory::SLOT_INGREDIENT);
|
||||||
|
if($ingredient->isNull()){
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$recipes = [];
|
$recipes = [];
|
||||||
|
$craftingManager = $this->position->getWorld()->getServer()->getCraftingManager();
|
||||||
foreach([BrewingStandInventory::SLOT_BOTTLE_LEFT, BrewingStandInventory::SLOT_BOTTLE_MIDDLE, BrewingStandInventory::SLOT_BOTTLE_RIGHT] as $slot){
|
foreach([BrewingStandInventory::SLOT_BOTTLE_LEFT, BrewingStandInventory::SLOT_BOTTLE_MIDDLE, BrewingStandInventory::SLOT_BOTTLE_RIGHT] as $slot){
|
||||||
$input = $this->inventory->getItem($slot);
|
$input = $this->inventory->getItem($slot);
|
||||||
if($input->isNull()){
|
if($input->isNull()){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(($recipe = $this->position->getWorld()->getServer()->getCraftingManager()->matchBrewingRecipe($input, $this->inventory->getItem(BrewingStandInventory::SLOT_INGREDIENT))) !== null){
|
if(($recipe = $craftingManager->matchBrewingRecipe($input, $ingredient)) !== null){
|
||||||
$recipes[$slot] = $recipe;
|
$recipes[$slot] = $recipe;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user