PrismarineJS / mineflayer

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

[Python] Radom disconnect #3015

Open JeffreyWangDev opened 1 year ago

JeffreyWangDev commented 1 year ago

Detailed description of a problem

Running the code below, sometimes returns a [JSE] TypeError: Cannot read properties of undefined (reading 'setBlockEntity'). This happens randomly and can not find the issue.

What did you try yet?

Did you try any method from the API? No calls, just messages Did you try any example? Any error from those?

Your current code


from javascript import require, On, Once, AsyncTask, once, off
import re
mineflayer = require('mineflayer')

bot = mineflayer.createBot({
    "username": '**',
    "password": '**',
    "auth": 'microsoft',        
    "host": "mc.hypixel.net",
    "version": "1.16.4",
    "logErrors": True,
    "hideErrors": True,
})

print("Started mineflayer")

@On(bot, 'spawn')
def handle(*args):
  @On(bot, 'chat')
  def handleMsg(this, sender, message, *args):
    if str(sender).lower() == "guild":
        print(message)

Error message [JSE] C:\Users\25wan\Documents\GitHub\python-bridge.venv\Lib\site-packages\javascript\js\node_modules\mineflayer\lib\plugins\blocks.js:417 [JSE] column.setBlockEntity(pos, packet.nbtData) [JSE] ^ [JSE] [JSE] TypeError: Cannot read properties of undefined (reading 'setBlockEntity') [JSE] at Client. (C:\Users\25wan\Documents\GitHub\python-bridge.venv\Lib\site-packages\javascript\js\node_modules\mineflayer\lib\plugins\blocks.js:417:14) [JSE] at Client.emit (node:events:513:28) [JSE] at FullPacketParser. (C:\Users\25wan\Documents\GitHub\python-bridge.venv\Lib\site-packages\javascript\js\node_modules\minecraft-protocol\src\client.js:91:12) [JSE] at FullPacketParser.emit (node:events:513:28) [JSE] at addChunk (C:\Users\25wan\Documents\GitHub\python-bridge.venv\Lib\site-packages\javascript\js\node_modules\protodef\node_modules\readable-stream\lib_stream_readable.js:279:12)
[JSE] at readableAddChunk (C:\Users\25wan\Documents\GitHub\python-bridge.venv\Lib\site-packages\javascript\js\node_modules\protodef\node_modules\readable-stream\lib_stream_readable.js:262:11) [JSE] at Readable.push (C:\Users\25wan\Documents\GitHub\python-bridge.venv\Lib\site-packages\javascript\js\node_modules\protodef\node_modules\readable-stream\lib_stream_readable.js:228:10) [JSE] at Transform.push (C:\Users\25wan\Documents\GitHub\python-bridge.venv\Lib\site-packages\javascript\js\node_modules\protodef\node_modules\readable-stream\lib_stream_transform.js:132:32) [JSE] at FullPacketParser._transform (C:\Users\25wan\Documents\GitHub\python-bridge.venv\Lib\site-packages\javascript\js\node_modules\protodef\src\serializer.js:89:10) [JSE] at Transform._read (C:\Users\25wan\Documents\GitHub\python-bridge.venv\Lib\site-packages\javascript\js\node_modules\protodef\node_modules\readable-stream\lib_stream_transform.js:166:10) [JSE] [JSE] Node.js v18.15.0

extremeheat commented 1 year ago

I believe this is a known issue on Hypixel. Try setting the version to 1.8