mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-20 16:00:20 +00:00
Fixed crash when opening crafting table and other 'UI' inventories
This commit is contained in:
parent
758b5ee500
commit
c9601ae67d
@ -141,10 +141,6 @@ class InventoryManager{
|
||||
}
|
||||
|
||||
private function addDynamic(Inventory $inventory) : int{
|
||||
if(isset($this->inventories[spl_object_id($inventory)])){
|
||||
throw new \InvalidArgumentException("Inventory " . get_class($inventory) . " is already tracked");
|
||||
}
|
||||
$this->inventories[spl_object_id($inventory)] = new InventoryManagerEntry($inventory);
|
||||
$id = $this->getNewWindowId();
|
||||
$this->add($id, $inventory);
|
||||
return $id;
|
||||
@ -168,6 +164,17 @@ class InventoryManager{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int[]|int $slotMap
|
||||
* @phpstan-param array<int, int>|int $slotMap
|
||||
*/
|
||||
private function addComplexDynamic(array|int $slotMap, Inventory $inventory) : int{
|
||||
$this->addComplex($slotMap, $inventory);
|
||||
$id = $this->getNewWindowId();
|
||||
$this->associateIdWithInventory($id, $inventory);
|
||||
return $id;
|
||||
}
|
||||
|
||||
private function remove(int $id) : void{
|
||||
$inventory = $this->networkIdToInventoryMap[$id];
|
||||
unset($this->networkIdToInventoryMap[$id]);
|
||||
@ -296,9 +303,10 @@ class InventoryManager{
|
||||
$this->onCurrentWindowRemove();
|
||||
|
||||
$this->openWindowDeferred(function() use ($inventory) : void{
|
||||
$windowId = $this->addDynamic($inventory);
|
||||
if(($slotMap = $this->createComplexSlotMapping($inventory)) !== null){
|
||||
$this->addComplex($slotMap, $inventory);
|
||||
$windowId = $this->addComplexDynamic($slotMap, $inventory);
|
||||
}else{
|
||||
$windowId = $this->addDynamic($inventory);
|
||||
}
|
||||
|
||||
foreach($this->containerOpenCallbacks as $callback){
|
||||
|
Loading…
x
Reference in New Issue
Block a user