Customize pathfinding behavior with the Movements class
masterThe Movements class configures how the pathfinder plans its paths, including block breaking, building, and movement costs. To change default behavior, create a new instance of Movements and pass it to bot.pathfinder.setMovements().
Example:
const { Movements } = require('mineflayer-pathfinder')
bot.once('spawn', () => {
const defaultMove = new Movements(bot)
defaultMove.allow1by1towers = false // Do not build 1x1 towers
defaultMove.canDig = false // Disable breaking blocks
defaultMove.scafoldingBlocks.push(bot.registry.itemsByName['netherrack'].id)
bot.pathfinder.setMovements(defaultMove)
})const { Movements } = require('mineflayer-pathfinder')
bot.once('spawn', () => {
const defaultMove = new Movements(bot)
defaultMove.allow1by1towers = false // Do not build 1x1 towers when going up
defaultMove.canDig = false // Disable breaking of blocks when pathing
defaultMove.scafoldingBlocks.push(bot.registry.itemsByName['netherrack'].id) // Add nether rack to allowed scaffolding items
bot.pathfinder.setMovements(defaultMove) // Update the movement instance pathfinder uses
// Do pathfinder things
// ...
})