JSPM

  • Created
  • Published
  • Downloads 19161
  • Score
    100M100P100Q194373F
  • License MIT

Package Exports

  • mineflayer-pathfinder

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (mineflayer-pathfinder) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Mineflayer-pathfinder

npm version npm

Pathfinding plugin. This is still a work in progress, feel free to contribute by making suggestions.

Install

npm install mineflayer-pathfinder

Example

const mineflayer = require('mineflayer')
const pathfinder = require('mineflayer-pathfinder').pathfinder
const Movements = require('mineflayer-pathfinder').Movements
const { GoalNear } = require('mineflayer-pathfinder').goals
const bot = mineflayer.createBot({ username: 'Player' })

bot.loadPlugin(pathfinder)

bot.once('spawn', () => {

  const mcData = require('minecraft-data')(bot.version)

  const defaultMove = new Movements(bot, mcData)
  
  bot.on('chat', function(username, message) {
  
    if (username === bot.username) return

    const target = bot.players[username].entity
    if (message === 'come') {
      if (!target) {
        bot.chat('I don\'t see you !')
        return
      }
      const p = target.position

      bot.pathfinder.setMovements(defaultMove)
      bot.pathfinder.setGoal(new GoalNear(p.x, p.y, p.z, 1))
    } 
})

Features

  • Optimized and modernized A* pathfinding
  • Complexe goals can be specified (inspired by baritone goals )
  • Customizable movements generator
  • Each movement can have a different cost
  • Can break/place blocks as part of its deplacement
  • Automatically update path when environment change
  • Long distance paths
  • Can swim

TODO

  • Make computations span multiple ticks
  • Ladders and vines
  • Parkour jumps
  • Limit search range
  • Make a modular api to configure the movements
  • Dynamic enemies avoidance
  • Dynamic harvest/mining paths
  • Sprint
  • Actual move speed per block
  • Consider enchantements in dig time