Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for a possible error in lib/plugins/entities.js file #3254

Merged
merged 5 commits into from
Dec 31, 2023

Conversation

Mykola1453
Copy link
Contributor

@Mykola1453 Mykola1453 commented Dec 27, 2023

I'm not sure if this error happens with vanilla Minecraft, but when I tried to use mineflayer with node-minecraft-protocol-forge, I receive the following error shortly after my bot joins a server with TeamAbnormals mods:

    entity.type = entityData.type || 'object'
                             ^

TypeError: Cannot read properties of undefined (reading 'type')

The pull request fixes this error by adding an if statement around entity.type = entityData.type || 'object' line.

Adding if statement around entity.type = entityData.type || 'object' to fix "TypeError: Cannot read properties of undefined (reading 'type')"
@@ -197,7 +197,9 @@ function inject (bot) {
const entity = fetchEntity(packet.entityId)
const entityData = bot.registry.entities[packet.type]

entity.type = entityData.type || 'object'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you rather move this line to setEntityData ?

@rom1504 rom1504 merged commit 15cfeb4 into PrismarineJS:master Dec 31, 2023
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Closed
Development

Successfully merging this pull request may close these issues.

2 participants