InventoryManager: be aware of client-side state when syncing slots

this eliminates feedback loops during client-initiated slot changes, and also makes it possible to have a SlotChangeAction anonymous from its initiator.
This commit is contained in:
Dylan K. Taylor
2020-02-11 21:12:18 +00:00
parent cd71a6204f
commit 4014f9a4f2
3 changed files with 29 additions and 7 deletions

View File

@ -79,11 +79,6 @@ class SlotChangeAction extends InventoryAction{
* Sets the item into the target inventory.
*/
public function execute(Player $source) : void{
$this->inventory->setItem($this->inventorySlot, $this->targetItem, false);
foreach($this->inventory->getViewers() as $viewer){
if($viewer !== $source){
$viewer->getNetworkSession()->getInvManager()->syncSlot($this->inventory, $this->inventorySlot);
}
}
$this->inventory->setItem($this->inventorySlot, $this->targetItem);
}
}