From 727e29a99cad6a4099f975c9d4bb645e8e694625 Mon Sep 17 00:00:00 2001 From: cha0s Date: Tue, 15 Oct 2019 02:15:47 -0500 Subject: [PATCH] refactor: targeted receptacle events --- common/traits/receptacle.trait.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/common/traits/receptacle.trait.js b/common/traits/receptacle.trait.js index 795a029..fafaf33 100644 --- a/common/traits/receptacle.trait.js +++ b/common/traits/receptacle.trait.js @@ -229,6 +229,7 @@ export class Receptacle extends decorate(Trait) { else { this.addListenersForItem(item); this.slotItems[slotIndex] = item; + this.entity.emit('itemAdded', item, slotIndex); if (AVOCADO_SERVER) { this.packetUpdates.push(new TraitUpdateReceptacleItemFullPacket({ slotIndex, @@ -247,6 +248,7 @@ export class Receptacle extends decorate(Trait) { } this.removeListenersForItem(item); delete this.slotItems[slotIndex]; + this.entity.emit('itemRemoved', item, slotIndex); if (AVOCADO_SERVER) { this.packetUpdates.push(new TraitUpdateReceptacleItemSwapPacket({ firstSlotIndex: slotIndex, @@ -282,6 +284,13 @@ export class Receptacle extends decorate(Trait) { this.slotItems[rightIndex] = leftItem; this.addListenersForItem(leftItem); this.addListenersForItem(rightItem); + this.entity.emit( + 'itemsSwapped', + leftIndex, + rightIndex, + leftItem, + rightItem + ); }, };