Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bot goes to unexpected ways #322

Open
MegalithOfficial opened this issue Jun 8, 2023 · 1 comment
Open

Bot goes to unexpected ways #322

MegalithOfficial opened this issue Jun 8, 2023 · 1 comment

Comments

@MegalithOfficial
Copy link

I expected to bot go in a square but it just goes randomly and then leaves the server, simply bot dont obey to code and literally breaks/puts block randomly
I also check that is the coordinates are true, yes the code gets the valid cordinates
My server on 1.19.3

import g, { pathfinder, Movements } from "mineflayer-pathfinder"
import mcdata from "minecraft-data";
import { mineflayer as mineflayerViewer } from 'prismarine-viewer';
import mineflayer from "mineflayer";
import { API } from "./api.js"

const api = new API();
const GoalBlock = g.goals.GoalBlock;

const bot = mineflayer.createBot({
    host: "noip",
    username: "BOT"
});
let botJoinedToServer = false;

bot.once("spawn", async () => {
    pathfinder(bot);
    const Data = mcdata("1.19.3")
    console.log(bot.version)
    const movements = new Movements(bot, Data);
    bot.pathfinder.setMovements(movements);
    start(bot);
    mineflayerViewer(bot, { port: 3000 })
});

async function start(bot) {
    if (!botJoinedToServer) {
        botJoinedToServer = true;
        walk().then(() => {
            bot.quit();
            botJoinedToServer = false;
        });
    }
}

async function walk() {
     const startPos = bot.entity.position

    for (let i = 0; i < 10; i++) {
         await bot.pathfinder.goto(new GoalBlock(startPos.x.toFixed(0) + 1, 62, startPos.z.toFixed(0)));
         await bot.pathfinder.goto(new GoalBlock(startPos.x.toFixed(0) + 1, 62, startPos.z.toFixed(0) + 1));
         await bot.pathfinder.goto(new GoalBlock(startPos.x.toFixed(0), 62, startPos.z.toFixed(0) + 1));
         await bot.pathfinder.goto(new GoalBlock(startPos.x.toFixed(0), 62, startPos.z.toFixed(0)));
    };
};
@MegalithOfficial
Copy link
Author

and bot gives timeout when it randomly moves

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant