Mineflayer starter: your first bot

Mineflayer is the JavaScript bot library under Mindcraft, Voyager and Steve. Per its docs it supports Minecraft 1.8 through 26.1.

1. Install

Install Node.js 18 or newer, then:

mkdir mybot && cd mybot
npm init -y
npm install mineflayer

2. Echo bot (from the official docs)

const mineflayer = require('mineflayer')

const bot = mineflayer.createBot({
  host: 'localhost',
  username: 'Bot',
  auth: 'microsoft' // use 'offline' for an offline-mode test server
})

bot.on('chat', (username, message) => {
  if (username === bot.username) return
  bot.chat(message)
})

bot.on('kicked', console.log)
bot.on('error', console.log)

Run with node bot.js. With auth: 'microsoft' you get a one-time device-code login. Use a spare account, not your main one.

3. Add movement

npm install mineflayer-pathfinder

Then load the plugin with bot.loadPlugin(pathfinder) and set goals like GoalNear. See the pathfinder README for the full API.

4. Next steps

Sources: Mineflayer docs · mineflayer-pathfinder

Weekly agent digest

New Minecraft bots, releases, guides and model results. One short email a week, free.

Unsubscribe anytime. See privacy.