2012-10-26 15:09:16 +02:00
|
|
|
import DataUtil
|
2012-04-15 18:49:47 +02:00
|
|
|
|
2012-10-26 12:31:47 +02:00
|
|
|
def send00(socket, KAid):
|
|
|
|
#packet id
|
|
|
|
socket.send("\x00")
|
2012-12-25 21:38:02 +01:00
|
|
|
|
2012-10-26 12:31:47 +02:00
|
|
|
#int - keep alive id
|
2012-10-26 15:09:16 +02:00
|
|
|
DataUtil.sendInt(socket, KAid)
|
2012-10-26 12:31:47 +02:00
|
|
|
|
2012-12-25 21:38:02 +01:00
|
|
|
|
2012-09-02 19:54:16 +02:00
|
|
|
def sendHandshake(socket, username, host, port):
|
|
|
|
#packet id
|
|
|
|
socket.send("\x02")
|
2012-12-25 21:38:02 +01:00
|
|
|
|
2012-09-02 19:54:16 +02:00
|
|
|
#byte - protocol version
|
2013-09-22 17:50:38 +02:00
|
|
|
DataUtil.sendByte(socket, 78)
|
2012-12-25 21:38:02 +01:00
|
|
|
|
2012-09-02 19:54:16 +02:00
|
|
|
#string - username
|
2012-10-26 15:09:16 +02:00
|
|
|
DataUtil.sendString(socket, username)
|
2012-12-25 21:38:02 +01:00
|
|
|
|
2012-09-02 19:54:16 +02:00
|
|
|
#string - server host
|
2012-10-26 15:09:16 +02:00
|
|
|
DataUtil.sendString(socket, host)
|
2012-12-25 21:38:02 +01:00
|
|
|
|
2012-09-02 19:54:16 +02:00
|
|
|
#int - server port
|
2012-10-26 15:09:16 +02:00
|
|
|
DataUtil.sendInt(socket, port)
|
2012-09-02 19:54:16 +02:00
|
|
|
|
2012-12-25 21:38:02 +01:00
|
|
|
|
2012-04-15 18:49:47 +02:00
|
|
|
def send03(socket, message):
|
2012-09-02 19:54:16 +02:00
|
|
|
#packet id
|
2012-04-15 18:49:47 +02:00
|
|
|
socket.send("\x03")
|
2012-12-25 21:38:02 +01:00
|
|
|
|
2012-09-02 19:54:16 +02:00
|
|
|
#-----string - message-----#
|
2012-10-26 15:09:16 +02:00
|
|
|
DataUtil.sendString(socket, message)
|
2012-12-25 21:38:02 +01:00
|
|
|
|
|
|
|
|
2012-09-02 19:54:16 +02:00
|
|
|
def sendCD(socket, payload):
|
|
|
|
#packet id
|
|
|
|
socket.send("\xCD")
|
2012-12-25 21:38:02 +01:00
|
|
|
|
2012-09-02 19:54:16 +02:00
|
|
|
#payload - byte
|
2012-10-26 15:09:16 +02:00
|
|
|
DataUtil.sendByte(socket, payload)
|
2012-12-25 21:38:02 +01:00
|
|
|
|
|
|
|
|
2012-09-02 19:54:16 +02:00
|
|
|
def sendFC(socket, secret, token):
|
|
|
|
#packet id
|
|
|
|
socket.send("\xFC")
|
2012-12-25 21:38:02 +01:00
|
|
|
|
2012-09-02 19:54:16 +02:00
|
|
|
#shared secret
|
2012-10-26 15:09:16 +02:00
|
|
|
DataUtil.sendShort(socket, secret.__len__()) #length
|
2012-09-02 19:54:16 +02:00
|
|
|
socket.send(secret)
|
2012-12-25 21:38:02 +01:00
|
|
|
|
2012-09-02 19:54:16 +02:00
|
|
|
#token
|
2012-10-26 15:09:16 +02:00
|
|
|
DataUtil.sendShort(socket, token.__len__())
|
2012-10-26 02:02:42 +02:00
|
|
|
socket.send(token)
|
2012-12-25 21:38:02 +01:00
|
|
|
|
|
|
|
|
2012-10-26 02:02:42 +02:00
|
|
|
def sendFF(socket, reason):
|
2012-10-26 15:09:16 +02:00
|
|
|
#string - disconnect reason
|
2013-07-24 18:02:17 +02:00
|
|
|
DataUtil.sendString(socket, reason)
|
2013-09-24 21:31:17 +02:00
|
|
|
|
|
|
|
|
|
|
|
#====
|
|
|
|
def send0B(socket, x, y, z, stance, onGround):
|
|
|
|
#packet id
|
|
|
|
socket.send("\x0B")
|
|
|
|
|
|
|
|
DataUtil.sendDouble(socket, x)
|
|
|
|
DataUtil.sendDouble(socket, y)
|
|
|
|
DataUtil.sendDouble(socket, stance)
|
|
|
|
DataUtil.sendDouble(socket, z)
|
|
|
|
DataUtil.sendBoolean(socket, onGround)
|
|
|
|
|
|
|
|
|
|
|
|
def send0D(socket, x, y, z, stance, yaw, pitch, onGround):
|
|
|
|
#packet id
|
|
|
|
socket.send("\x0D")
|
|
|
|
|
|
|
|
DataUtil.sendDouble(socket, x)
|
|
|
|
DataUtil.sendDouble(socket, y)
|
|
|
|
DataUtil.sendDouble(socket, stance)
|
|
|
|
DataUtil.sendDouble(socket, z)
|
|
|
|
DataUtil.sendFloat(socket, yaw)
|
|
|
|
DataUtil.sendFloat(socket, pitch)
|
|
|
|
DataUtil.sendBoolean(socket, onGround)
|
|
|
|
|
|
|
|
|
|
|
|
def sendCA(socket, flags, flySpeed, walkSpeed):
|
|
|
|
#packet id
|
|
|
|
socket.send("\xCA")
|
|
|
|
|
|
|
|
DataUtil.sendByte(socket, flags)
|
|
|
|
DataUtil.sendFloat(socket, flySpeed)
|
|
|
|
DataUtil.sendFloat(socket, walkSpeed)
|