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 can't detect mobs #3183

Closed
Visivel opened this issue Sep 2, 2023 · 4 comments
Closed

Bot can't detect mobs #3183

Visivel opened this issue Sep 2, 2023 · 4 comments
Labels
possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f

Comments

@Visivel
Copy link

Visivel commented Sep 2, 2023

Versions

  • mineflayer: "^4.13.0
  • server: vanilla

My code

const mineflayer = require('mineflayer')

const bot = mineflayer.createBot({
    host: 'localhost',
    port: 123,
    username: "MyBot"
})

bot.once('spawn', () => {
    setInterval(() => {
        const mobFilter = e => e.type === 'mob' && e.mobType === 'Zombie'
        const mob = bot.nearestEntity(mobFilter)

        if (!mob) return;

        const pos = mob.position;
        bot.lookAt(pos, true, () => {
            bot.attack(mob, true);
        });
    }, 1000);
});

Ye, that's it, it just doesn't detect, i already tried Chat GPT and a lot of stuff but it just doesn't works

@Visivel Visivel added possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f labels Sep 2, 2023
@WhoTho
Copy link
Contributor

WhoTho commented Sep 10, 2023

Callbacks are not supported, so the attack function wont work.

As for the bot not detecting mobs at all, try e.name instead of e.mobType

@rom1504
Copy link
Member

rom1504 commented Sep 10, 2023 via email

@Visivel
Copy link
Author

Visivel commented Oct 11, 2023

Tell chatgpt to use promises instead of callbacks

On Sun, Sep 10, 2023, 21:44 WhoTho @.> wrote: Callbacks are not supported, so the attack function wont work. As for the bot not detecting mobs at all, try e.name instead of e.mobType — Reply to this email directly, view it on GitHub <#3183 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAR437VRAO2SY7THPMEH5UDXZYDAXANCNFSM6AAAAAA4IHVRTE . You are receiving this because you are subscribed to this thread.Message ID: @.>

this example is a copy of https://www.youtube.com/watch?v=walbRk20KYU. Thanks to Dude from CI, but still not working, i tried to remove "e.mobType" but still not working.

i also tried that:

const mineflayer = require('mineflayer')

const bot = mineflayer.createBot({
    host: 'localhost',
    port: 55879,
    username: "MyBot",
    verison: 1.19
})

bot.once('spawn', () => {
    setInterval(() => {
        const mobFilter = e => e.type === 'mob'// && e.mobType === 'Zombie'
        const mob = bot.nearestEntity(mobFilter)

        if (!mob) {
            console.log("Where is le mob?")
            return
        }

        const pos = mob.position.offset(0, mob.height, 0)
        bot.lookAt(pos)
        bot.attack(mob)
    }, 1000);
});

@Visivel
Copy link
Author

Visivel commented Oct 11, 2023

alr, nvm, i found a way to fix it. Thanks everyone for the support, specially me being lil dumbie :p

here is the fixed code:

const mineflayer = require('mineflayer')

const bot = mineflayer.createBot({
    host: 'localhost',
    port: 55879,
    username: "MyBot",
    verison: 1.19
})

bot.once('spawn', () => {
    setInterval(() => {
        const mob = bot.nearestEntity(entity => entity.name.toLowerCase() === 'zombie')

        if (!mob) {
            console.log("Nenhum mob identificado")
            return
        }

        const pos = mob.position.offset(0, mob.height, 0)
        bot.lookAt(pos)
        bot.attack(mob)
    }, 1000);
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f
Projects
None yet
Development

No branches or pull requests

4 participants