PrismarineJS / mineflayer

Create Minecraft bots with a powerful, stable, and high level JavaScript API.
https://prismarinejs.github.io/mineflayer/
MIT License
4.95k stars 904 forks source link

Finding entity helpers #75

Closed yocontra closed 11 years ago

yocontra commented 11 years ago

What do you think about having Entity have nearest(filter), nearestWithinRange(filter) 6 block range default, nearestObject(), nearestMob(), nearestMobWithinRange(), nearestPlayer(), nearestPlayerWithinRange()

Finding entities relative to other entities would be fun. I want to make a bot that stands around PvP and when a player gets close enough to attack another player (6 blocks) it will say watch out X is trying to kill you.

I have this working with my radar plugin - just wanted your opinion before I add it to Entity and send a pull req

andrewrk commented 11 years ago

A couple more options:

  1. "extras"

    In addition to the "plugins" folder we have an "extras" folder. These are plugins that are not enabled by default. Like you suggested before, you can use bot.use('radar') to inject the extra into your bot.

  2. separate project

    Installation would look something like require('mineflayer-radar')(bot).

    The benefits of this are:

    • you can version lock the separate project to the correct version of mineflayer
    • I, as the maintainer of mineflayer, do not become responsible for maintaining all the code that would have been in extras/
    • the plugin can have additional npm dependencies without requiring mineflayer itself to depend on them

Also, I will expose all the classes on mineflayer in the next release, such as Entity, Block, etc. so if you want to add properties / methods to these classes you can.

yocontra commented 11 years ago

Sweet if the classes are exposed I can quit annoying you with issues :+1: