diff --git a/src/inventory/transaction/SlotChangeActionBuilder.php b/src/inventory/transaction/SlotChangeActionBuilder.php index 90fe2111a..7fe2490d9 100644 --- a/src/inventory/transaction/SlotChangeActionBuilder.php +++ b/src/inventory/transaction/SlotChangeActionBuilder.php @@ -106,9 +106,10 @@ final class SlotChangeActionBuilder extends BaseInventory{ */ public function generateActions() : array{ $result = []; + $inventory = $this->inventoryWindow->getInventory(); foreach($this->changedSlots as $index => $newItem){ if($newItem !== null){ - $oldItem = $this->inventoryWindow->getInventory()->getItem($index); + $oldItem = $inventory->getItem($index); if(!$newItem->equalsExact($oldItem)){ $result[] = new SlotChangeAction($this->inventoryWindow, $index, $oldItem, $newItem); } diff --git a/src/network/mcpe/InventoryManager.php b/src/network/mcpe/InventoryManager.php index b9c095f8c..0334527af 100644 --- a/src/network/mcpe/InventoryManager.php +++ b/src/network/mcpe/InventoryManager.php @@ -615,7 +615,8 @@ class InventoryManager implements InventoryListener{ } private function syncContents(InventoryWindow $window) : void{ - $entry = $this->getEntry($window->getInventory()); + $inventory = $window->getInventory(); + $entry = $this->getEntry($inventory); if($entry === null){ //this can happen when an inventory changed during InventoryCloseEvent, or when a temporary inventory //is cleared before removal. @@ -631,7 +632,7 @@ class InventoryManager implements InventoryListener{ $entry->pendingSyncs = []; $contents = []; $typeConverter = $this->session->getTypeConverter(); - foreach($window->getInventory()->getContents(true) as $slot => $item){ + foreach($inventory->getContents(true) as $slot => $item){ $itemStack = $typeConverter->coreItemStackToNet($item); $info = $this->trackItemStack($entry, $slot, $itemStack, null); $contents[] = new ItemStackWrapper($info->getStackId(), $itemStack);