BrewingStand: avoid duplicate method call (#4874)

This commit is contained in:
Rush2929 2022-03-03 02:32:56 +09:00 committed by GitHub
parent f181c60209
commit d47a7f48bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -148,18 +148,20 @@ class BrewingStand extends Spawnable implements Container, Nameable{
* @phpstan-return array<int, BrewingRecipe>
*/
private function getBrewableRecipes() : array{
if($this->inventory->getItem(BrewingStandInventory::SLOT_INGREDIENT)->isNull()){
$ingredient = $this->inventory->getItem(BrewingStandInventory::SLOT_INGREDIENT);
if($ingredient->isNull()){
return [];
}
$recipes = [];
$craftingManager = $this->position->getWorld()->getServer()->getCraftingManager();
foreach([BrewingStandInventory::SLOT_BOTTLE_LEFT, BrewingStandInventory::SLOT_BOTTLE_MIDDLE, BrewingStandInventory::SLOT_BOTTLE_RIGHT] as $slot){
$input = $this->inventory->getItem($slot);
if($input->isNull()){
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;
}
}