Closed ranguli closed 4 years ago
Sure why not, you can add it there https://github.com/PrismarineJS/mineflayer/blob/master/lib/plugins/entities.js
optionally, we can add a matcher function parameter like bot.nearestEntity(matcher=(entity)=>true)
so we can customize the type and attributes of returned entities (default to all entities)
I second the matching function idea. This function could basically be treated as a sibling to findBlock.
Is your feature request related to a problem? Please describe.
In order to get the nearest entity to a bot, (to my knowledge) one must implement a
nearestEntity()
function something like inexamples/looker.js
, seen here. I think this task is fairly common, and we could prevent code re-use by adding it to the library.Describe the solution you'd like
It would be great if something like
bot.nearestEntity()
existed that simply did what is done in thelooker.js
example. I'd be happy to make a PR copying that function over if someone can advise on what the appropriate place would be in the codebase for it to go.Describe alternatives you've considered
The main alternative I considered is to simply re-implement that function on each project every time myself or someone else needs it, or stuff it in some sort of 'misc' plugin.