Python - send login packet to Minecraft Server

邮差的信 提交于 2020-01-16 19:45:23

问题


Is there a way to send a login packet to minecraft server from python?
Here is what i have right now:

import socket
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
addr = ("localhost", 25565)
client.connect(addr)
client.sendall(chr(0x02))
client.sendall(chr(0xFD))
client.sendall(chr(0xCD)) # After sending this line server still don't kick me
client.sendall(chr(0x06)+str(117)+str(70)+str(-46)) # And now server kicks me :-(
client.sendall(chr(0x03)+str("Hello World"))
print client.recv(4096)
client.close()


Hope there is a way to do this :-).

EDIT:

BTW, I'd like to send login packets with non-premium username (or one that doesn't exists), if it is possible :-) )


回答1:


An alternative would be to use someone-else's python library that does it for you - like quarry or others mentioned here. Also see this related question.



来源:https://stackoverflow.com/questions/18316462/python-send-login-packet-to-minecraft-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!