/** * @param Player $source * * Sends a slot update to inventory viewers * For successful transactions, update non-source viewers (source does not need updating) * For failed transactions, update the source (non-source viewers will see nothing anyway) */ public function sendSlotUpdate(Player $source) { if ($this->getInventory() instanceof TemporaryInventory) { return; } $targets = []; if ($this->wasSuccessful) { $targets = $this->getInventory()->getViewers(); unset($targets[spl_object_hash($source)]); } else { $targets = [$source]; } $this->inventory->sendSlot($this->slot, $targets); }