Skip to content

Instantly share code, notes, and snippets.

@Themis3000
Created March 31, 2021 05:37
Show Gist options
  • Save Themis3000/2dbd7f055891d3ebeea77a50989b2988 to your computer and use it in GitHub Desktop.
Save Themis3000/2dbd7f055891d3ebeea77a50989b2988 to your computer and use it in GitHub Desktop.
minecraft afk bot
const mineflayer = require('mineflayer')
const autoeat = require("mineflayer-auto-eat")
const pathfinder = require('mineflayer-pathfinder').pathfinder
const Movements = require('mineflayer-pathfinder').Movements
const { GoalNear } = require('mineflayer-pathfinder').goals
//where to afk
const afk_cords = [39794, 201, -39182]
//within how many blocks of afk spot to get
const afk_range = 2
//island to visit
const island = "Your Island"
const bot = mineflayer.createBot({
host: 'skyblock.net',
port: 25565,
username: 'username',
password: 'pass',
version: false,
auth: 'mojang'
})
bot.loadPlugin(autoeat)
bot.loadPlugin(pathfinder)
bot.once("spawn", () => {
//handles auto eat
bot.autoEat.options = {
priority: "foodPoints",
startAt: 14,
bannedFood: [],
}
bot.autoEat.enable()
//Goes to island
bot.chat(`/visit ${island}`)
//handles pathfinding
const mcData = require('minecraft-data')(bot.version)
const defaultMove = new Movements(bot, mcData)
//disables digging
defaultMove.canDig = false
bot.pathfinder.setMovements(defaultMove)
//sets pathfinding goal
bot.pathfinder.setGoal(new GoalNear(afk_cords[0], afk_cords[1], afk_cords[2], afk_range))
console.log('bot has started pathfinding...')
bot.once('goal_reached', function () {
console.log('in position')
//goes into sneak mode
//comment this out if you'd like
setTimeout(() => bot.setControlState('sneak', true), 1000)
})
})
bot.on('kicked', (reason, loggedIn) => console.log(`Kicked! ${reason} ${loggedIn}`))
bot.on('error', err => console.log(`Error! ${err}`))
bot.on('end', () => console.log('Disconnected!'))
console.log("started!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment