File size: 836 Bytes
36ba3ef | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | const mineflayer = require('mineflayer')
const mineflayerViewer = require('prismarine-viewer').mineflayer
const { pathfinder, Movements } = require('mineflayer-pathfinder')
const { GoalXZ } = require('mineflayer-pathfinder').goals
const bot = mineflayer.createBot({
username: 'Bot'
})
bot.loadPlugin(pathfinder)
bot.once('spawn', () => {
mineflayerViewer(bot, { firstPerson: true, port: 3000 })
const path = [bot.entity.position.clone()]
bot.on('move', () => {
if (path[path.length - 1].distanceTo(bot.entity.position) > 1) {
path.push(bot.entity.position.clone())
bot.viewer.drawLine('path', path)
}
})
const mcData = require('minecraft-data')(bot.version)
const defaultMove = new Movements(bot, mcData)
bot.pathfinder.setMovements(defaultMove)
bot.pathfinder.setGoal(new GoalXZ(1000, 0))
}) |