mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-04 00:59:51 +00:00
Avoid unnecessary repeated calls
This commit is contained in:
parent
1738355357
commit
7f58122ac6
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user