PrismarineJS / mineflayer

Create Minecraft bots with a powerful, stable, and high level JavaScript API.
https://prismarinejs.github.io/mineflayer/
MIT License
4.95k stars 904 forks source link

bot.look is not a function #918

Closed Dufftwt closed 4 years ago

Dufftwt commented 4 years ago

Versions

Detailed description of a problem

When I use a function of bot (bot.look() in this case), this throws a TypeError (bot.look is not a function)

Context code (I don't think it comes from this snippet the full code is lower)

bot.on("chat", (username, message) =>{
                // if(username === bot.username) return;
                let date_ob = new Date();
                let date = ("0" + date_ob.getDate()).slice(-2);
                let day = date_ob.getDay();
                let month = ("0" + (date_ob.getMonth() + 1)).slice(-2);
                let year = date_ob.getFullYear();
                let hours = date_ob.getHours();
                let minutes = date_ob.getMinutes();
                let seconds = date_ob.getSeconds();
                let curMes = day + "-" + month + "-" + year + " " + hours + ":" + minutes + " <" + username + ">" + message;
                console.log(curMes);
                fs.appendFile('logmess.txt', curMes + "\n" , function (err) {
                        if (err) throw err;
                        console.log('Saved!');
            });
            if(message === "!start"){
                bot.look(bot.entity.yaw + 180, bot.entity.pitch);

            }

            })

Full Code

The full code is available here because I don't think the error comes from the above context code since it worked without the if statement https://github.com/SWEDCODER/pofd-proxy/blob/master/pofdPublic.js

Expected behavior

I expected the bot to rotate its head 180 degrees

Additional context

It's a proxy bot which transfers packets from a fake player connected on a remote server to a localhost server and vice-versa, I am actually trying to make it a chatbot while being able to play on it

rom1504 commented 4 years ago

What is the full error ?

On Tue, Mar 3, 2020, 21:23 SWED_CODER notifications@github.com wrote:

Versions

  • mineflayer: 2.11.0
  • server: paper
  • node: 13

Detailed description of a problem

When I use a function of bot (bot.look() in this case), this throws a TypeError (bot.look is not a function) Context code (I don't think it comes from this snippet the full code is lower)

bot.on("chat", (username, message) =>{ // if(username === bot.username) return; let date_ob = new Date(); let date = ("0" + date_ob.getDate()).slice(-2); let day = date_ob.getDay(); let month = ("0" + (date_ob.getMonth() + 1)).slice(-2); let year = date_ob.getFullYear(); let hours = date_ob.getHours(); let minutes = date_ob.getMinutes(); let seconds = date_ob.getSeconds(); let curMes = day + "-" + month + "-" + year + " " + hours + ":" + minutes + " <" + username + ">" + message; console.log(curMes); fs.appendFile('logmess.txt', curMes + "\n" , function (err) { if (err) throw err; console.log('Saved!'); }); if(message === "!start"){ bot.look(bot.entity.yaw + 180, bot.entity.pitch);

      }

      })

Full Code

The full code is available here because I don't think the error comes from the above context code since it worked without the if statement https://github.com/SWEDCODER/pofd-proxy/blob/master/pofdPublic.js Expected behavior

I expected the bot to rotate its head 180 degrees Additional context

It's a proxy bot which transfers packets from a fake player connected on a remote server to a localhost server and vice-versa, I am actually trying to make it a chatbot while being able to play on it

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/PrismarineJS/mineflayer/issues/918?email_source=notifications&email_token=AAR437R62HPVZ5AIZLYJUZLRFVRLPA5CNFSM4LASJ3B2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4ISER6SA, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAR437XXUUVLQS5SNHWFWRTRFVRLPANCNFSM4LASJ3BQ .

Dufftwt commented 4 years ago

Thanks for the quick response, you're a boss! The full error is here: https://pastebin.com/reLGJ9zf

rom1504 commented 4 years ago

The reason you got this error is you disabled the physics plugin. bot.look is part of this plugin. You need to enable it.

On Tue, Mar 3, 2020, 23:09 SWED_CODER notifications@github.com wrote:

Thanks for the quick response, you're a boss! The full log is here: https://pastebin.com/reLGJ9zf

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/PrismarineJS/mineflayer/issues/918?email_source=notifications&email_token=AAR437QA3CAFERUGKXGD4BDRFV53JA5CNFSM4LASJ3B2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENVLQYQ#issuecomment-594196578, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAR437WXDTAIIV22UFRBD73RFV53JANCNFSM4LASJ3BQ .

Dufftwt commented 4 years ago

Oh god, okay, I'm such an idiot, thank you I'm going to try this, if it works I'll close the issue

Dufftwt commented 4 years ago

Oh, activating physics actually make the game lag so much, I remember why now. Thank you so much it works now, I'm closing this