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

getDroppedItem may throw error on some entities #37

Open
IceTank opened this issue Apr 12, 2022 · 0 comments
Open

getDroppedItem may throw error on some entities #37

IceTank opened this issue Apr 12, 2022 · 0 comments

Comments

@IceTank
Copy link
Contributor

IceTank commented Apr 12, 2022

I used getDroppedItem on entities in the bots render distance and got this error once

TypeError: Cannot read properties of undefined (reading 'blockId')
     at Function.fromNotch (/home/pi/Documents/mineflayer-auto-shepherd/node_modules/prismarine-item/index.js:81:18)
     at Entity.getDroppedItem (/home/pi/Documents/mineflayer-auto-shepherd/node_modules/prismarine-entity/index.js:44:19)
     at /home/pi/Documents/mineflayer-auto-shepherd/dist/plugins/autoShepherd.js:27:98
     at Array.filter (<anonymous>)

The server is running on paper 1.12.2 and there should not be any weird entities around.
I don't know how to reproduce that error as it only happened once
The code calling the function looks like this

const droppedItems = Object.values(bot.entities).filter(e => {
  return e.name === 'item' && e.position.distanceTo(bot.entity.position) < 30 && e.getDroppedItem()?.name?.includes('wool')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant