Skip to content

Commit

Permalink
Fix for a possible error in lib/plugins/entities.js file (#3254)
Browse files Browse the repository at this point in the history
* Update entities.js

Adding if statement around entity.type = entityData.type || 'object' to fix "TypeError: Cannot read properties of undefined (reading 'type')"

* Update entities.js

* Update entities.js

* Update entities.js
  • Loading branch information
Mykola1453 committed Dec 31, 2023
1 parent 931a418 commit 15cfeb4
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/plugins/entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -196,8 +197,6 @@ function inject (bot) {
bot._client.on('spawn_entity', (packet) => {
const entity = fetchEntity(packet.entityId)
const entityData = bot.registry.entities[packet.type]

entity.type = entityData.type || 'object'
setEntityData(entity, packet.type, entityData)

if (bot.supportFeature('fixedPointPosition')) {
Expand Down

0 comments on commit 15cfeb4

Please sign in to comment.