Sending Login Packet to Minecraft Server in Python Not Working

只愿长相守 提交于 2019-12-04 12:27:13

It seems you're not adding the string or the empty fields;

packetbytes = struct.pack('>bihshiibBB', 1, 23, len(data['user']), enc_user, 0, 0, 0, 0, 0, 0)

About the second h in the packing format, a Minecraft string is greater or equal than 2 bytes in length. So I'm assuming that an empty string is just a short with the value 0.

Edit: The abovementioned method doesn't work; the s needs a length;

packfmt = '>bih{}shiibBB'.format(len(enc_user))
packetbytes = struct.pack(packfmt, 1, 23, len(data['user']), enc_user, 0, 0, 0, 0, 0, 0)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!