From 6b0ac8adb839bc65cb64e389b874e18527df78e9 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 24 Sep 2017 19:16:50 +0100 Subject: [PATCH] Don't overwrite the input map with reindexed stuff we might need this again? --- .../transaction/CraftingTransaction.php | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/pocketmine/inventory/transaction/CraftingTransaction.php b/src/pocketmine/inventory/transaction/CraftingTransaction.php index 14f4e7e45..157cf97c6 100644 --- a/src/pocketmine/inventory/transaction/CraftingTransaction.php +++ b/src/pocketmine/inventory/transaction/CraftingTransaction.php @@ -40,8 +40,6 @@ class CraftingTransaction extends InventoryTransaction{ /** @var Item|null */ protected $primaryOutput; - private $isReindexed = false; - /** @var CraftingRecipe|null */ protected $recipe = null; @@ -97,11 +95,7 @@ class CraftingTransaction extends InventoryTransaction{ return $this->recipe; } - private function reindexInputs() : void{ - if($this->isReindexed){ - return; - } - + private function reindexInputs() : array{ $xOffset = $this->gridSize; $yOffset = $this->gridSize; @@ -121,7 +115,7 @@ class CraftingTransaction extends InventoryTransaction{ } if($height === 0 or $width === 0){ - return; + return []; } $air = ItemFactory::get(Item::AIR, 0, 0); @@ -132,15 +126,13 @@ class CraftingTransaction extends InventoryTransaction{ } } - $this->inputs = $reindexed; - - $this->isReindexed = true; + return $reindexed; } public function canExecute() : bool{ - $this->reindexInputs(); + $inputs = $this->reindexInputs(); - $this->recipe = $this->source->getServer()->getCraftingManager()->matchRecipe($this->inputs, $this->primaryOutput, $this->secondaryOutputs); + $this->recipe = $this->source->getServer()->getCraftingManager()->matchRecipe($inputs, $this->primaryOutput, $this->secondaryOutputs); return $this->recipe !== null and parent::canExecute(); }