diff --git a/packages/entity/entity.synchronized.js b/packages/entity/entity.synchronized.js index 5e7102c..692fb7f 100644 --- a/packages/entity/entity.synchronized.js +++ b/packages/entity/entity.synchronized.js @@ -386,6 +386,10 @@ export class Entity extends decorate(Resource) { } } + toNetwork() { + return this.mergeDiff(); + } + toJSON() { const json = {}; for (const type in this._traits) { diff --git a/packages/entity/list/index.js b/packages/entity/list/index.js index 2aed160..37b85d0 100644 --- a/packages/entity/list/index.js +++ b/packages/entity/list/index.js @@ -35,18 +35,17 @@ export class EntityList extends decorate(class {}) { if (packet instanceof EntityListUpdateEntityPacket) { for (let i = 0; i < packet.data.length; i++) { const {uuid, packets} = packet.data[i]; - // WHY ? - if (!this._entities[uuid]) { - continue; - } for (let j = 0; j < packets.length; j++) { - this._entities[uuid].acceptPacket(packets[j]); + if (this._entities[uuid]) { + this._entities[uuid].acceptPacket(packets[j]); + } } } } if (packet instanceof SynchronizedCreatePacket) { - const entity = new Entity(packet.data.spec); - this.addEntity(entity); + Entity.loadOrInstance(packet.data.spec).then((entity) => { + this.addEntity(entity); + }); } if (packet instanceof SynchronizedDestroyPacket) { const uuid = packet.data.synchronized.id;