From 29abc9f540c7a5d951310c6b940e37f9bcf13ef7 Mon Sep 17 00:00:00 2001 From: cha0s Date: Tue, 14 May 2019 03:41:38 -0500 Subject: [PATCH] fix: remove last --- packages/entity/list/index.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/entity/list/index.js b/packages/entity/list/index.js index 2d939b4..cb5252d 100644 --- a/packages/entity/list/index.js +++ b/packages/entity/list/index.js @@ -81,11 +81,6 @@ export class EntityList extends decorate(class {}) { packets.push(new EntityCreatePacket(entity.toJSON(), entity)); } this._entitiesJustAdded = []; - for (let i = 0; i < this._entitiesJustRemoved.length; i++) { - const entity = this._entitiesJustRemoved[i]; - packets.push(new EntityRemovePacket({}, entity)); - } - this._entitiesJustRemoved = []; } for (let i = 0; i < this._flatEntities.length; i++) { const entityPackets = this._flatEntities[i].packetsForUpdate(force); @@ -93,6 +88,13 @@ export class EntityList extends decorate(class {}) { packets.push(entityPackets[j]); } } + if (!force) { + for (let i = 0; i < this._entitiesJustRemoved.length; i++) { + const entity = this._entitiesJustRemoved[i]; + packets.push(new EntityRemovePacket({}, entity)); + } + this._entitiesJustRemoved = []; + } return packets; }