PrismarineJS / mineflayer

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

Bot won't spawn in Minecraft #3475

Closed m1kelgood closed 1 month ago

m1kelgood commented 1 month ago

I'm in VSCode using Python (3.12.1) to create a bot in my Minecraft (java edition 1.20.4) using Mineflayer (0.0.14) (Node v20.16.0). I've attached the code and error I get when attempting to create the bot. I've tried with different LANs and ensured that the port number is correct, turned off some firewalls in Windows Defender firewall, and a couple of other things, all getting the same result. At this point, I'm lost and don't know why the bot won't spawn. I would greatly appreciate any help.

code:

from javascript import require, On
mineflayer = require('mineflayer')

bot = mineflayer.createBot(
    {
        'host': '127.0.0.1',
        'port': 63595,
        'username': 'python'
    }
)

Error: connect ECONNREFUSED 127.0.0.1:63595 at TCPConnectWrap.afterConnect [as incomplete] (node:net:1607:16) { erno: -111, code: ' ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 63595 }

AkagawaTsurunaki commented 1 month ago

mineflayer@0.0.14 is too old (released on Jan 27, 2013) to support Minecraft 1.20.4 (released around 2023).

Newer Minecraft may change the protocol between server and client. So just try out the latest version of mineflayer!

I used Node v20.17.0 to run npm install mineflayer@0.0.14, but too many compiling errors occurred so I failed to reproduce your issue.

But the good news is that the latest mineflayer@4.20.0 is supported Minecraft 1.20.4, even 1.20.6. I test your code and this time everything went well.