From cb7ff547738d5cace5d71a40872cb5dab9bac6a4 Mon Sep 17 00:00:00 2001 From: Mykola1453 <69845760+Mykola1453@users.noreply.github.com> Date: Wed, 27 Dec 2023 15:04:11 +0200 Subject: [PATCH 1/4] Update entities.js Adding if statement around entity.type = entityData.type || 'object' to fix "TypeError: Cannot read properties of undefined (reading 'type')" --- lib/plugins/entities.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/plugins/entities.js b/lib/plugins/entities.js index cb507bb7e..36919e230 100644 --- a/lib/plugins/entities.js +++ b/lib/plugins/entities.js @@ -197,7 +197,9 @@ function inject (bot) { const entity = fetchEntity(packet.entityId) const entityData = bot.registry.entities[packet.type] - entity.type = entityData.type || 'object' + if (entityData) { + entity.type = entityData.type || 'object' + } setEntityData(entity, packet.type, entityData) if (bot.supportFeature('fixedPointPosition')) { From 63895486d738f3df343f6363d32317f91f3d1c8d Mon Sep 17 00:00:00 2001 From: Mykola1453 <69845760+Mykola1453@users.noreply.github.com> Date: Sun, 31 Dec 2023 11:49:37 +0200 Subject: [PATCH 2/4] Update entities.js --- lib/plugins/entities.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/plugins/entities.js b/lib/plugins/entities.js index 36919e230..b635bf2f0 100644 --- a/lib/plugins/entities.js +++ b/lib/plugins/entities.js @@ -176,6 +176,7 @@ function inject (bot) { entityData = entitiesArray.find(entity => entity.internalId === type) } if (entityData) { + entity.type = entityData.type || 'object' entity.displayName = entityData.displayName entity.entityType = entityData.id entity.name = entityData.name @@ -196,10 +197,7 @@ function inject (bot) { bot._client.on('spawn_entity', (packet) => { const entity = fetchEntity(packet.entityId) const entityData = bot.registry.entities[packet.type] - - if (entityData) { - entity.type = entityData.type || 'object' - } + setEntityData(entity, packet.type, entityData) if (bot.supportFeature('fixedPointPosition')) { From 60aa7be5854fa23b03d8d8fcffadb41ddb750d34 Mon Sep 17 00:00:00 2001 From: Mykola1453 <69845760+Mykola1453@users.noreply.github.com> Date: Sun, 31 Dec 2023 11:58:21 +0200 Subject: [PATCH 3/4] Update entities.js --- lib/plugins/entities.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/plugins/entities.js b/lib/plugins/entities.js index b635bf2f0..8c4630e6a 100644 --- a/lib/plugins/entities.js +++ b/lib/plugins/entities.js @@ -197,9 +197,8 @@ function inject (bot) { bot._client.on('spawn_entity', (packet) => { const entity = fetchEntity(packet.entityId) const entityData = bot.registry.entities[packet.type] - setEntityData(entity, packet.type, entityData) - + if (bot.supportFeature('fixedPointPosition')) { entity.position.set(packet.x / 32, packet.y / 32, packet.z / 32) } else if (bot.supportFeature('doublePosition')) { From 0d50eaa700bb4ab058c4ab7e1ece1b967cb962c6 Mon Sep 17 00:00:00 2001 From: Mykola1453 <69845760+Mykola1453@users.noreply.github.com> Date: Sun, 31 Dec 2023 12:07:43 +0200 Subject: [PATCH 4/4] Update entities.js --- lib/plugins/entities.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/plugins/entities.js b/lib/plugins/entities.js index 8c4630e6a..8ee6f6742 100644 --- a/lib/plugins/entities.js +++ b/lib/plugins/entities.js @@ -198,7 +198,7 @@ function inject (bot) { const entity = fetchEntity(packet.entityId) const entityData = bot.registry.entities[packet.type] setEntityData(entity, packet.type, entityData) - + if (bot.supportFeature('fixedPointPosition')) { entity.position.set(packet.x / 32, packet.y / 32, packet.z / 32) } else if (bot.supportFeature('doublePosition')) {