mineflayer-pathfinder icon indicating copy to clipboard operation
mineflayer-pathfinder copied to clipboard

Can't move the bot

Open Dashbloxx opened this issue 1 year ago • 3 comments

I am working on a small bot that I'm making for a Minecraft server, but for some reason, the bot won't move to the coordinates that are specified...

const mineflayer = require('mineflayer')
const { pathfinder, Movements, goals } = require('mineflayer-pathfinder')
const GoalFollow = goals.GoalFollow
const GoalBlock = goals.GoalBlock
const password = 'HIDDEN'

const bot = mineflayer.createBot({
    host: '6b6t.org',
    port: 25565,
    username: 'HIDDEN'
})

bot.loadPlugin(pathfinder)

bot.once("login", () => {
    bot.chat(`/login ${password}`);
});

bot.once("spawn", () => {
    const goal = new GoalBlock(-17, 88, 0)
    bot.pathfinder.setGoal(goal)
});

The exact code that is failing to work, is:

const goal = new GoalBlock(-17, 88, 0)
bot.pathfinder.setGoal(goal)

When I run the first code snippet, the bot just stays online on the server, but doesn't move at all...

Dashbloxx avatar Jul 23 '22 18:07 Dashbloxx

you arent calling the bot to go to the goal

WOAHHHHHHHHH avatar Jul 29 '22 16:07 WOAHHHHHHHHH

What do you mean? What is the function to make the bot go to the goal?

I've updated the code several times, even using exact code examples from different tutorials from youtube and here, and it still won't work...

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({ host: '6b6t.org', username: 'HIDDEN', version: '1.12.2' })
//const reader = require("readline-sync");

bot.loadPlugin(pathfinder)

bot.once('spawn', () => {
    const mcData = require('minecraft-data')(bot.version)
    const defaultMove = new Movements(bot, mcData)
    bot.pathfinder.setMovements(defaultMove)
    bot.pathfinder.setGoal(new GoalNear(-17, 88, 0), true)
})

Dashbloxx avatar Aug 01 '22 16:08 Dashbloxx

The login event is to soon to do anything in game. The login event is fired when the bot is send the login packet. This happens before even chunk start to load. My guess is that this bot.chat(/login ${password}) line fails. So the bot tries to move but is blocked by the server. Use setTimeout or waitForChunks to load before chatting in game. On spawn might work too.

IceTank avatar Aug 21 '22 09:08 IceTank