mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-15 18:29:46 +00:00
InventoryManager: avoid feedback loop when closing inventory
This commit is contained in:
parent
b108fb61bf
commit
55e3b9ed91
@ -137,6 +137,16 @@ class InventoryManager{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function onClientRemoveWindow(int $id) : void{
|
||||||
|
if($id === $this->lastInventoryNetworkId){
|
||||||
|
unset($this->windowMap[$id]);
|
||||||
|
unset($this->initiatedSlotChanges[$id]);
|
||||||
|
$this->player->removeCurrentWindow();
|
||||||
|
}else{
|
||||||
|
$this->session->getLogger()->debug("Attempted to close inventory with network ID $id, but current is $this->lastInventoryNetworkId");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function syncSlot(Inventory $inventory, int $slot) : void{
|
public function syncSlot(Inventory $inventory, int $slot) : void{
|
||||||
$windowId = $this->getWindowId($inventory);
|
$windowId = $this->getWindowId($inventory);
|
||||||
if($windowId !== null){
|
if($windowId !== null){
|
||||||
|
@ -496,14 +496,9 @@ class InGamePacketHandler extends PacketHandler{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$window = $this->player->getCurrentWindow();
|
$this->session->getInvManager()->onClientRemoveWindow($packet->windowId);
|
||||||
if($window !== null and $packet->windowId === $this->session->getInvManager()->getCurrentWindowId()){
|
|
||||||
$this->player->removeCurrentWindow();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->session->getLogger()->debug("Attempted to close inventory with network ID $packet->windowId, but current is " . $this->session->getInvManager()->getCurrentWindowId());
|
return true;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handlePlayerHotbar(PlayerHotbarPacket $packet) : bool{
|
public function handlePlayerHotbar(PlayerHotbarPacket $packet) : bool{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user