mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-13 06:55:29 +00:00
parent
27e0ecf7ee
commit
58bc9332cd
@ -215,7 +215,17 @@ class InventoryManager{
|
|||||||
$currentItem = $inventory->getItem($slot);
|
$currentItem = $inventory->getItem($slot);
|
||||||
$clientSideItem = $this->initiatedSlotChanges[$windowId][$slot] ?? null;
|
$clientSideItem = $this->initiatedSlotChanges[$windowId][$slot] ?? null;
|
||||||
if($clientSideItem === null or !$clientSideItem->equalsExact($currentItem)){
|
if($clientSideItem === null or !$clientSideItem->equalsExact($currentItem)){
|
||||||
$this->session->sendDataPacket(InventorySlotPacket::create($windowId, $slot, ItemStackWrapper::legacy(TypeConverter::getInstance()->coreItemStackToNet($currentItem))));
|
$itemStackWrapper = ItemStackWrapper::legacy(TypeConverter::getInstance()->coreItemStackToNet($currentItem));
|
||||||
|
if($windowId === ContainerIds::OFFHAND){
|
||||||
|
//TODO: HACK!
|
||||||
|
//The client may sometimes ignore the InventorySlotPacket for the offhand slot.
|
||||||
|
//This can cause a lot of problems (totems, arrows, and more...).
|
||||||
|
//The workaround is to send an InventoryContentPacket instead
|
||||||
|
//BDS (Bedrock Dedicated Server) also seems to work this way.
|
||||||
|
$this->session->sendDataPacket(InventoryContentPacket::create($windowId, [$itemStackWrapper]));
|
||||||
|
}else{
|
||||||
|
$this->session->sendDataPacket(InventorySlotPacket::create($windowId, $slot, $itemStackWrapper));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
unset($this->initiatedSlotChanges[$windowId][$slot]);
|
unset($this->initiatedSlotChanges[$windowId][$slot]);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user