Closed Garfield100 closed 4 years ago
The dynamic goals can emit the goal_reached event multiple time, that would not fit well with callbacks. The choice of using events was made to work with all types of goals.
It is easy enough to wrap the plugin to use callback in your code:
function gotoGoalCallback(goal, callback) {
bot.pathfinder.setGoal(goal)
bot.once('goal_reached', callback)
}
Forgive me, I was unaware that .once
could be used like that. That actually makes all of mineflayer a lot easier 😅
thank you
I know the mineflayer stuff is more event-based but being able to set a callback would be very useful to more easily string together actions. It's very easy to add to the
inject
function. Should I make a pull request?