Formatting
This commit is contained in:
1 parent
2abe34e88c
commit
d9199a3e2a
11 files changed
+440
-355
No files matched your search
@@ -7,12 +7,13 @@ from hashlib import sha1
|
|||||||
# This function courtesy of barneygale
|
# This function courtesy of barneygale
|
||||||
def javaHexDigest(digest):
|
def javaHexDigest(digest):
|
||||||
d = long(digest.hexdigest(), 16)
|
d = long(digest.hexdigest(), 16)
|
||||||
if d >> 39*4 & 0x8:
|
if d >> 39 * 4 & 0x8:
|
||||||
d = "-%x" % ((-d) & (2**(40*4)-1))
|
d = "-%x" % ((-d) & (2 ** (40 * 4) - 1))
|
||||||
else:
|
else:
|
||||||
d = "%x" % d
|
d = "%x" % d
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
|
||||||
def translate_escape(m):
|
def translate_escape(m):
|
||||||
c = m.group(1).lower()
|
c = m.group(1).lower()
|
||||||
|
|
||||||
@@ -41,35 +42,37 @@ def translate_escape(m):
|
|||||||
|
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
def translate_escapes(s):
|
def translate_escapes(s):
|
||||||
return re.sub(ur"\xa7([0-9a-zA-Z])", translate_escape, s) + "\x1b[0m"
|
return re.sub(ur"\xa7([0-9a-zA-Z])", translate_escape, s) + "\x1b[0m"
|
||||||
|
|
||||||
|
|
||||||
def loginToMinecraft(username, password):
|
def loginToMinecraft(username, password):
|
||||||
try:
|
try:
|
||||||
url = 'https://login.minecraft.net'
|
url = 'https://login.minecraft.net'
|
||||||
header = {'Content-Type' : 'application/x-www-form-urlencoded'}
|
header = {'Content-Type': 'application/x-www-form-urlencoded'}
|
||||||
data = {'user' : username,
|
data = {'user': username,
|
||||||
'password' : password,
|
'password': password,
|
||||||
'version' : '13'}
|
'version': '13'}
|
||||||
data = urllib.urlencode(data)
|
data = urllib.urlencode(data)
|
||||||
req = urllib2.Request(url, data, header)
|
req = urllib2.Request(url, data, header)
|
||||||
opener = urllib2.build_opener()
|
opener = urllib2.build_opener()
|
||||||
response = opener.open(req, None, 10)
|
response = opener.open(req, None, 10)
|
||||||
response = response.read()
|
response = response.read()
|
||||||
except urllib2.URLError:
|
except urllib2.URLError:
|
||||||
return {'Response' : "Can't connect to minecraft.net"}
|
return {'Response': "Can't connect to minecraft.net"}
|
||||||
if(not "deprecated" in response.lower()):
|
if (not "deprecated" in response.lower()):
|
||||||
return {'Response' : response}
|
return {'Response': response}
|
||||||
response = response.split(":")
|
response = response.split(":")
|
||||||
sessionid = response[3]
|
sessionid = response[3]
|
||||||
toReturn = {'Response' : "Good to go!",
|
toReturn = {'Response': "Good to go!",
|
||||||
'Username' : response[2],
|
'Username': response[2],
|
||||||
'SessionID' : sessionid
|
'SessionID': sessionid
|
||||||
}
|
}
|
||||||
return toReturn
|
return toReturn
|
||||||
|
|
||||||
class MinecraftLoginThread(threading.Thread):
|
|
||||||
|
|
||||||
|
class MinecraftLoginThread(threading.Thread):
|
||||||
def __init__(self, username, password):
|
def __init__(self, username, password):
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
self.username = username
|
self.username = username
|
||||||
|
|||||||
+35
-12
@@ -6,72 +6,93 @@ from pynbt import NBTFile
|
|||||||
def readBoolean(FileObject):
|
def readBoolean(FileObject):
|
||||||
return struct.unpack('?', FileObject.read(1))[0]
|
return struct.unpack('?', FileObject.read(1))[0]
|
||||||
|
|
||||||
|
|
||||||
def readByte(FileObject):
|
def readByte(FileObject):
|
||||||
return struct.unpack('>b', FileObject.read(1))[0]
|
return struct.unpack('>b', FileObject.read(1))[0]
|
||||||
|
|
||||||
|
|
||||||
def readUnsignedByte(FileObject):
|
def readUnsignedByte(FileObject):
|
||||||
return struct.unpack('>B', FileObject.read(1))[0]
|
return struct.unpack('>B', FileObject.read(1))[0]
|
||||||
|
|
||||||
|
|
||||||
def readShort(FileObject):
|
def readShort(FileObject):
|
||||||
return struct.unpack('>h', FileObject.read(2))[0]
|
return struct.unpack('>h', FileObject.read(2))[0]
|
||||||
|
|
||||||
|
|
||||||
def readUnsignedShort(FileObject):
|
def readUnsignedShort(FileObject):
|
||||||
return struct.unpack('>H', FileObject.read(2))[0]
|
return struct.unpack('>H', FileObject.read(2))[0]
|
||||||
|
|
||||||
|
|
||||||
def readInt(FileObject):
|
def readInt(FileObject):
|
||||||
return struct.unpack('>i', FileObject.read(4))[0]
|
return struct.unpack('>i', FileObject.read(4))[0]
|
||||||
|
|
||||||
|
|
||||||
def readFloat(FileObject):
|
def readFloat(FileObject):
|
||||||
return struct.unpack('>f', FileObject.read(4))[0]
|
return struct.unpack('>f', FileObject.read(4))[0]
|
||||||
|
|
||||||
|
|
||||||
def readLong(FileObject):
|
def readLong(FileObject):
|
||||||
return struct.unpack('>q', FileObject.read(8))[0]
|
return struct.unpack('>q', FileObject.read(8))[0]
|
||||||
|
|
||||||
|
|
||||||
def readDouble(FileObject):
|
def readDouble(FileObject):
|
||||||
return struct.unpack('>d', FileObject.read(8))[0]
|
return struct.unpack('>d', FileObject.read(8))[0]
|
||||||
|
|
||||||
|
|
||||||
def readByteArray(FileObject, length):
|
def readByteArray(FileObject, length):
|
||||||
return struct.unpack(str(length) + "s", FileObject.read(length))[0]
|
return struct.unpack(str(length) + "s", FileObject.read(length))[0]
|
||||||
|
|
||||||
|
|
||||||
def readString(FileObject):
|
def readString(FileObject):
|
||||||
length = readShort(FileObject) * 2
|
length = readShort(FileObject) * 2
|
||||||
return FileObject.read(length).decode("utf-16be")
|
return FileObject.read(length).decode("utf-16be")
|
||||||
|
|
||||||
|
|
||||||
def sendBoolean(socket, value):
|
def sendBoolean(socket, value):
|
||||||
assert type(value) is types.BooleanType, "value is not a boolean: %r" % value
|
assert type(value) is types.BooleanType, "value is not a boolean: %r" % value
|
||||||
socket.send(struct.pack('?', value))
|
socket.send(struct.pack('?', value))
|
||||||
|
|
||||||
|
|
||||||
def sendByte(socket, value):
|
def sendByte(socket, value):
|
||||||
socket.send(struct.pack('>b', value))
|
socket.send(struct.pack('>b', value))
|
||||||
|
|
||||||
|
|
||||||
def sendUnsignedByte(socket, value):
|
def sendUnsignedByte(socket, value):
|
||||||
socket.send(struct.pack('>B', value))
|
socket.send(struct.pack('>B', value))
|
||||||
|
|
||||||
|
|
||||||
def sendShort(socket, value):
|
def sendShort(socket, value):
|
||||||
socket.send(struct.pack('>h', value))
|
socket.send(struct.pack('>h', value))
|
||||||
|
|
||||||
|
|
||||||
def sendUnsignedShort(socket, value):
|
def sendUnsignedShort(socket, value):
|
||||||
socket.send(struct.pack('>H', value))
|
socket.send(struct.pack('>H', value))
|
||||||
|
|
||||||
|
|
||||||
def sendInt(socket, value):
|
def sendInt(socket, value):
|
||||||
assert type(value) is types.IntType, "value is not an integer: %r" % value
|
assert type(value) is types.IntType, "value is not an integer: %r" % value
|
||||||
socket.send(struct.pack('>i', value))
|
socket.send(struct.pack('>i', value))
|
||||||
|
|
||||||
|
|
||||||
def sendFloat(socket, value):
|
def sendFloat(socket, value):
|
||||||
socket.send(struct.pack('>f', value))
|
socket.send(struct.pack('>f', value))
|
||||||
|
|
||||||
|
|
||||||
def sendLong(socket, value):
|
def sendLong(socket, value):
|
||||||
socket.send(struct.pack('>q', value))
|
socket.send(struct.pack('>q', value))
|
||||||
|
|
||||||
|
|
||||||
def sendDouble(socket, value):
|
def sendDouble(socket, value):
|
||||||
socket.send(struct.pack('>d', value))
|
socket.send(struct.pack('>d', value))
|
||||||
|
|
||||||
|
|
||||||
def sendString(socket, value):
|
def sendString(socket, value):
|
||||||
if (type(value) is not types.StringType):
|
if (type(value) is not types.StringType):
|
||||||
value = str(value)
|
value = str(value)
|
||||||
socket.send(struct.pack('>h', value.__len__()))
|
socket.send(struct.pack('>h', value.__len__()))
|
||||||
socket.send(value.encode('utf-16be'))
|
socket.send(value.encode('utf-16be'))
|
||||||
|
|
||||||
|
|
||||||
def readEntityMetadata(FileObject):
|
def readEntityMetadata(FileObject):
|
||||||
metadata = {}
|
metadata = {}
|
||||||
byte = readUnsignedByte(FileObject)
|
byte = readUnsignedByte(FileObject)
|
||||||
@@ -92,7 +113,8 @@ def readEntityMetadata(FileObject):
|
|||||||
val["damage"] = readShort(FileObject)
|
val["damage"] = readShort(FileObject)
|
||||||
nbtDataLength = readShort(FileObject)
|
nbtDataLength = readShort(FileObject)
|
||||||
if (nbtDataLength != -1):
|
if (nbtDataLength != -1):
|
||||||
val["NBT"] = NBTFile(BytesIO(readByteArray(FileObject, nbtDataLength)), compression=NBTFile.Compression.GZIP)
|
val["NBT"] = NBTFile(BytesIO(readByteArray(FileObject, nbtDataLength)),
|
||||||
|
compression=NBTFile.Compression.GZIP)
|
||||||
if ty == 6:
|
if ty == 6:
|
||||||
val = []
|
val = []
|
||||||
for i in range(3):
|
for i in range(3):
|
||||||
@@ -101,24 +123,25 @@ def readEntityMetadata(FileObject):
|
|||||||
byte = readUnsignedByte(FileObject)
|
byte = readUnsignedByte(FileObject)
|
||||||
return metadata
|
return metadata
|
||||||
|
|
||||||
|
|
||||||
def readSlotData(FileObject):
|
def readSlotData(FileObject):
|
||||||
BlockID = readShort(FileObject)
|
BlockID = readShort(FileObject)
|
||||||
if(BlockID != -1):
|
if (BlockID != -1):
|
||||||
ItemCount = readByte(FileObject)
|
ItemCount = readByte(FileObject)
|
||||||
Damage = readShort(FileObject)
|
Damage = readShort(FileObject)
|
||||||
MetadataLength = readShort(FileObject)
|
MetadataLength = readShort(FileObject)
|
||||||
if(MetadataLength != -1):
|
if (MetadataLength != -1):
|
||||||
ByteArray = readByteArray(FileObject, MetadataLength)
|
ByteArray = readByteArray(FileObject, MetadataLength)
|
||||||
NBTData = NBTFile(BytesIO(ByteArray), compression=NBTFile.Compression.GZIP)
|
NBTData = NBTFile(BytesIO(ByteArray), compression=NBTFile.Compression.GZIP)
|
||||||
return {'BlockID' : BlockID,
|
return {'BlockID': BlockID,
|
||||||
'ItemCount' : ItemCount,
|
'ItemCount': ItemCount,
|
||||||
'Damage' : Damage,
|
'Damage': Damage,
|
||||||
'Data' : NBTData
|
'Data': NBTData
|
||||||
}
|
}
|
||||||
return {'BlockID' : BlockID,
|
return {'BlockID': BlockID,
|
||||||
'ItemCount' : ItemCount,
|
'ItemCount': ItemCount,
|
||||||
'Damage' : Damage
|
'Damage': Damage
|
||||||
}
|
}
|
||||||
return {'BlockID' : -1,
|
return {'BlockID': -1,
|
||||||
'ItemCount' : 0
|
'ItemCount': 0
|
||||||
}
|
}
|
||||||
@@ -17,7 +17,6 @@ from Crypto.Cipher import PKCS1_v1_5
|
|||||||
EntityID = 0
|
EntityID = 0
|
||||||
|
|
||||||
class ServerConnection(threading.Thread):
|
class ServerConnection(threading.Thread):
|
||||||
|
|
||||||
def __init__(self, pluginLoader, username, sessionID, server, port, options=None):
|
def __init__(self, pluginLoader, username, sessionID, server, port, options=None):
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
self.pluginLoader = pluginLoader
|
self.pluginLoader = pluginLoader
|
||||||
@@ -42,8 +41,8 @@ class ServerConnection(threading.Thread):
|
|||||||
def run(self):
|
def run(self):
|
||||||
try:
|
try:
|
||||||
#Create the socket and fileobject
|
#Create the socket and fileobject
|
||||||
self.socket = socket.socket ( socket.AF_INET, socket.SOCK_STREAM )
|
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
self.socket.connect ( ( self.server, self.port ) )
|
self.socket.connect(( self.server, self.port ))
|
||||||
self.FileObject = self.socket.makefile()
|
self.FileObject = self.socket.makefile()
|
||||||
|
|
||||||
#Send out the handshake packet
|
#Send out the handshake packet
|
||||||
@@ -65,7 +64,7 @@ class ServerConnection(threading.Thread):
|
|||||||
self.sharedSecret = _UserFriendlyRNG.get_random_bytes(16)
|
self.sharedSecret = _UserFriendlyRNG.get_random_bytes(16)
|
||||||
|
|
||||||
#Authenticate the server from sessions.minecraft.net
|
#Authenticate the server from sessions.minecraft.net
|
||||||
if(packetFD['ServerID'] != '-'):
|
if (packetFD['ServerID'] != '-'):
|
||||||
try:
|
try:
|
||||||
#Grab the server id
|
#Grab the server id
|
||||||
sha1 = hashlib.sha1()
|
sha1 = hashlib.sha1()
|
||||||
@@ -78,7 +77,7 @@ class ServerConnection(threading.Thread):
|
|||||||
url = "http://session.minecraft.net/game/joinserver.jsp?user=" + self.username + "&sessionId=" + self.sessionID + "&serverId=" + serverid
|
url = "http://session.minecraft.net/game/joinserver.jsp?user=" + self.username + "&sessionId=" + self.sessionID + "&serverId=" + serverid
|
||||||
response = urllib2.urlopen(url).read()
|
response = urllib2.urlopen(url).read()
|
||||||
|
|
||||||
if(response != "OK"):
|
if (response != "OK"):
|
||||||
print "Response from sessions.minecraft.net wasn't OK, it was " + response
|
print "Response from sessions.minecraft.net wasn't OK, it was " + response
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -119,8 +118,8 @@ class ServerConnection(threading.Thread):
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
class EncryptedFileObjectHandler():
|
|
||||||
|
|
||||||
|
class EncryptedFileObjectHandler():
|
||||||
def __init__(self, fileobject, cipher):
|
def __init__(self, fileobject, cipher):
|
||||||
self.fileobject = fileobject
|
self.fileobject = fileobject
|
||||||
self.cipher = cipher
|
self.cipher = cipher
|
||||||
@@ -135,8 +134,8 @@ class EncryptedFileObjectHandler():
|
|||||||
def tell(self):
|
def tell(self):
|
||||||
return self.length
|
return self.length
|
||||||
|
|
||||||
class EncryptedSocketObjectHandler():
|
|
||||||
|
|
||||||
|
class EncryptedSocketObjectHandler():
|
||||||
def __init__(self, socket, cipher):
|
def __init__(self, socket, cipher):
|
||||||
self.socket = socket
|
self.socket = socket
|
||||||
self.cipher = cipher
|
self.cipher = cipher
|
||||||
@@ -147,8 +146,8 @@ class EncryptedSocketObjectHandler():
|
|||||||
def close(self):
|
def close(self):
|
||||||
self.socket.close()
|
self.socket.close()
|
||||||
|
|
||||||
class PacketListener(threading.Thread):
|
|
||||||
|
|
||||||
|
class PacketListener(threading.Thread):
|
||||||
def __init__(self, connection, socket, FileObject):
|
def __init__(self, connection, socket, FileObject):
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
self.connection = connection
|
self.connection = connection
|
||||||
@@ -183,144 +182,145 @@ class PacketListener(threading.Thread):
|
|||||||
if (response == ""):
|
if (response == ""):
|
||||||
continue
|
continue
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
if(self.window):
|
if (self.window):
|
||||||
self.window.Status.SetLabel("Ping timeout")
|
self.window.Status.SetLabel("Ping timeout")
|
||||||
else:
|
else:
|
||||||
print "Ping timeout"
|
print "Ping timeout"
|
||||||
sys.exit()
|
sys.exit()
|
||||||
break
|
break
|
||||||
if(response == "\x00"):
|
if (response == "\x00"):
|
||||||
packet = PacketListenerManager.handle00(self.FileObject, self.socket)
|
packet = PacketListenerManager.handle00(self.FileObject, self.socket)
|
||||||
elif(response == "\x01"):
|
elif (response == "\x01"):
|
||||||
packet = PacketListenerManager.handle01(self.FileObject)
|
packet = PacketListenerManager.handle01(self.FileObject)
|
||||||
print "Logged in \o/ Received an entity id of " + str(packet['EntityID'])
|
print "Logged in \o/ Received an entity id of " + str(packet['EntityID'])
|
||||||
elif(response == "\x03"):
|
elif (response == "\x03"):
|
||||||
packet = PacketListenerManager.handle03(self.FileObject)
|
packet = PacketListenerManager.handle03(self.FileObject)
|
||||||
# Add "\x1b" because it is essential for ANSI escapes emitted by translate_escapes
|
# Add "\x1b" because it is essential for ANSI escapes emitted by translate_escapes
|
||||||
filtered_string = filter(lambda x: x in string.printable + "\x1b", Utils.translate_escapes(packet['Message']))
|
filtered_string = filter(lambda x: x in string.printable + "\x1b",
|
||||||
|
Utils.translate_escapes(packet['Message']))
|
||||||
print filtered_string
|
print filtered_string
|
||||||
|
|
||||||
elif(response == "\x04"):
|
elif (response == "\x04"):
|
||||||
packet = PacketListenerManager.handle04(self.FileObject)
|
packet = PacketListenerManager.handle04(self.FileObject)
|
||||||
elif(response == "\x05"):
|
elif (response == "\x05"):
|
||||||
packet = PacketListenerManager.handle05(self.FileObject)
|
packet = PacketListenerManager.handle05(self.FileObject)
|
||||||
elif(response == "\x06"):
|
elif (response == "\x06"):
|
||||||
packet = PacketListenerManager.handle06(self.FileObject)
|
packet = PacketListenerManager.handle06(self.FileObject)
|
||||||
elif(response == "\x07"):
|
elif (response == "\x07"):
|
||||||
packet = PacketListenerManager.handle07(self.FileObject)
|
packet = PacketListenerManager.handle07(self.FileObject)
|
||||||
elif(response == "\x08"):
|
elif (response == "\x08"):
|
||||||
packet = PacketListenerManager.handle08(self.FileObject)
|
packet = PacketListenerManager.handle08(self.FileObject)
|
||||||
elif(response == "\x09"):
|
elif (response == "\x09"):
|
||||||
packet = PacketListenerManager.handle09(self.FileObject)
|
packet = PacketListenerManager.handle09(self.FileObject)
|
||||||
elif(response == "\x0D"):
|
elif (response == "\x0D"):
|
||||||
packet = PacketListenerManager.handle0D(self.FileObject)
|
packet = PacketListenerManager.handle0D(self.FileObject)
|
||||||
elif(response == "\x10"):
|
elif (response == "\x10"):
|
||||||
packet = PacketListenerManager.handle10(self.FileObject)
|
packet = PacketListenerManager.handle10(self.FileObject)
|
||||||
elif(response == "\x11"):
|
elif (response == "\x11"):
|
||||||
packet = PacketListenerManager.handle11(self.FileObject)
|
packet = PacketListenerManager.handle11(self.FileObject)
|
||||||
elif(response == "\x12"):
|
elif (response == "\x12"):
|
||||||
packet = PacketListenerManager.handle12(self.FileObject)
|
packet = PacketListenerManager.handle12(self.FileObject)
|
||||||
elif(response == "\x14"):
|
elif (response == "\x14"):
|
||||||
packet = PacketListenerManager.handle14(self.FileObject)
|
packet = PacketListenerManager.handle14(self.FileObject)
|
||||||
elif(response == "\x15"):
|
elif (response == "\x15"):
|
||||||
packet = PacketListenerManager.handle15(self.FileObject)
|
packet = PacketListenerManager.handle15(self.FileObject)
|
||||||
elif(response == "\x16"):
|
elif (response == "\x16"):
|
||||||
packet = PacketListenerManager.handle16(self.FileObject)
|
packet = PacketListenerManager.handle16(self.FileObject)
|
||||||
elif(response == "\x17"):
|
elif (response == "\x17"):
|
||||||
packet = PacketListenerManager.handle17(self.FileObject)
|
packet = PacketListenerManager.handle17(self.FileObject)
|
||||||
elif(response == "\x18"):
|
elif (response == "\x18"):
|
||||||
packet = PacketListenerManager.handle18(self.FileObject)
|
packet = PacketListenerManager.handle18(self.FileObject)
|
||||||
elif(response == "\x19"):
|
elif (response == "\x19"):
|
||||||
packet = PacketListenerManager.handle19(self.FileObject)
|
packet = PacketListenerManager.handle19(self.FileObject)
|
||||||
elif(response == "\x1A"):
|
elif (response == "\x1A"):
|
||||||
packet = PacketListenerManager.handle1A(self.FileObject)
|
packet = PacketListenerManager.handle1A(self.FileObject)
|
||||||
elif(response == "\x1C"):
|
elif (response == "\x1C"):
|
||||||
packet = PacketListenerManager.handle1C(self.FileObject)
|
packet = PacketListenerManager.handle1C(self.FileObject)
|
||||||
elif(response == "\x1D"):
|
elif (response == "\x1D"):
|
||||||
packet = PacketListenerManager.handle1D(self.FileObject)
|
packet = PacketListenerManager.handle1D(self.FileObject)
|
||||||
elif(response == "\x1E"):
|
elif (response == "\x1E"):
|
||||||
packet = PacketListenerManager.handle1E(self.FileObject)
|
packet = PacketListenerManager.handle1E(self.FileObject)
|
||||||
elif(response == "\x1F"):
|
elif (response == "\x1F"):
|
||||||
packet = PacketListenerManager.handle1F(self.FileObject)
|
packet = PacketListenerManager.handle1F(self.FileObject)
|
||||||
elif(response == "\x20"):
|
elif (response == "\x20"):
|
||||||
packet = PacketListenerManager.handle20(self.FileObject)
|
packet = PacketListenerManager.handle20(self.FileObject)
|
||||||
elif(response == "\x21"):
|
elif (response == "\x21"):
|
||||||
packet = PacketListenerManager.handle21(self.FileObject)
|
packet = PacketListenerManager.handle21(self.FileObject)
|
||||||
elif(response == "\x22"):
|
elif (response == "\x22"):
|
||||||
packet = PacketListenerManager.handle22(self.FileObject)
|
packet = PacketListenerManager.handle22(self.FileObject)
|
||||||
elif(response == "\x23"):
|
elif (response == "\x23"):
|
||||||
packet = PacketListenerManager.handle23(self.FileObject)
|
packet = PacketListenerManager.handle23(self.FileObject)
|
||||||
elif(response == "\x26"):
|
elif (response == "\x26"):
|
||||||
packet = PacketListenerManager.handle26(self.FileObject)
|
packet = PacketListenerManager.handle26(self.FileObject)
|
||||||
elif(response == "\x27"):
|
elif (response == "\x27"):
|
||||||
packet = PacketListenerManager.handle27(self.FileObject)
|
packet = PacketListenerManager.handle27(self.FileObject)
|
||||||
elif(response == "\x28"):
|
elif (response == "\x28"):
|
||||||
packet = PacketListenerManager.handle28(self.FileObject)
|
packet = PacketListenerManager.handle28(self.FileObject)
|
||||||
elif(response == "\x29"):
|
elif (response == "\x29"):
|
||||||
packet = PacketListenerManager.handle29(self.FileObject)
|
packet = PacketListenerManager.handle29(self.FileObject)
|
||||||
elif(response == "\x2A"):
|
elif (response == "\x2A"):
|
||||||
packet = PacketListenerManager.handle2A(self.FileObject)
|
packet = PacketListenerManager.handle2A(self.FileObject)
|
||||||
elif(response == "\x2B"):
|
elif (response == "\x2B"):
|
||||||
packet = PacketListenerManager.handle2B(self.FileObject)
|
packet = PacketListenerManager.handle2B(self.FileObject)
|
||||||
elif(response == "\x33"):
|
elif (response == "\x33"):
|
||||||
packet = PacketListenerManager.handle33(self.FileObject)
|
packet = PacketListenerManager.handle33(self.FileObject)
|
||||||
elif(response == "\x34"):
|
elif (response == "\x34"):
|
||||||
packet = PacketListenerManager.handle34(self.FileObject)
|
packet = PacketListenerManager.handle34(self.FileObject)
|
||||||
elif(response == "\x35"):
|
elif (response == "\x35"):
|
||||||
packet = PacketListenerManager.handle35(self.FileObject)
|
packet = PacketListenerManager.handle35(self.FileObject)
|
||||||
elif(response == "\x36"):
|
elif (response == "\x36"):
|
||||||
packet = PacketListenerManager.handle36(self.FileObject)
|
packet = PacketListenerManager.handle36(self.FileObject)
|
||||||
elif(response == "\x37"):
|
elif (response == "\x37"):
|
||||||
packet = PacketListenerManager.handle37(self.FileObject)
|
packet = PacketListenerManager.handle37(self.FileObject)
|
||||||
elif(response == "\x38"):
|
elif (response == "\x38"):
|
||||||
packet = PacketListenerManager.handle38(self.FileObject)
|
packet = PacketListenerManager.handle38(self.FileObject)
|
||||||
elif(response == "\x3C"):
|
elif (response == "\x3C"):
|
||||||
packet = PacketListenerManager.handle3C(self.FileObject)
|
packet = PacketListenerManager.handle3C(self.FileObject)
|
||||||
elif(response == "\x3D"):
|
elif (response == "\x3D"):
|
||||||
packet = PacketListenerManager.handle3D(self.FileObject)
|
packet = PacketListenerManager.handle3D(self.FileObject)
|
||||||
elif(response == "\x3E"):
|
elif (response == "\x3E"):
|
||||||
packet = PacketListenerManager.handle3E(self.FileObject)
|
packet = PacketListenerManager.handle3E(self.FileObject)
|
||||||
elif(response == "\x46"):
|
elif (response == "\x46"):
|
||||||
packet = PacketListenerManager.handle46(self.FileObject)
|
packet = PacketListenerManager.handle46(self.FileObject)
|
||||||
elif(response == "\x47"):
|
elif (response == "\x47"):
|
||||||
packet = PacketListenerManager.handle47(self.FileObject)
|
packet = PacketListenerManager.handle47(self.FileObject)
|
||||||
elif(response == "\x64"):
|
elif (response == "\x64"):
|
||||||
packet = PacketListenerManager.handle64(self.FileObject)
|
packet = PacketListenerManager.handle64(self.FileObject)
|
||||||
elif(response == "\x65"):
|
elif (response == "\x65"):
|
||||||
packet = PacketListenerManager.handle65(self.FileObject)
|
packet = PacketListenerManager.handle65(self.FileObject)
|
||||||
elif(response == "\x67"):
|
elif (response == "\x67"):
|
||||||
packet = PacketListenerManager.handle67(self.FileObject)
|
packet = PacketListenerManager.handle67(self.FileObject)
|
||||||
elif(response == "\x68"):
|
elif (response == "\x68"):
|
||||||
packet = PacketListenerManager.handle68(self.FileObject)
|
packet = PacketListenerManager.handle68(self.FileObject)
|
||||||
elif(response == "\x69"):
|
elif (response == "\x69"):
|
||||||
packet = PacketListenerManager.handle69(self.FileObject)
|
packet = PacketListenerManager.handle69(self.FileObject)
|
||||||
elif(response == "\x6A"):
|
elif (response == "\x6A"):
|
||||||
packet = PacketListenerManager.handle6A(self.FileObject)
|
packet = PacketListenerManager.handle6A(self.FileObject)
|
||||||
elif(response == "\x6B"):
|
elif (response == "\x6B"):
|
||||||
packet = PacketListenerManager.handle6B(self.FileObject)
|
packet = PacketListenerManager.handle6B(self.FileObject)
|
||||||
elif(response == "\x82"):
|
elif (response == "\x82"):
|
||||||
packet = PacketListenerManager.handle82(self.FileObject)
|
packet = PacketListenerManager.handle82(self.FileObject)
|
||||||
elif(response == "\x83"):
|
elif (response == "\x83"):
|
||||||
packet = PacketListenerManager.handle83(self.FileObject)
|
packet = PacketListenerManager.handle83(self.FileObject)
|
||||||
elif(response == "\x84"):
|
elif (response == "\x84"):
|
||||||
packet = PacketListenerManager.handle84(self.FileObject)
|
packet = PacketListenerManager.handle84(self.FileObject)
|
||||||
elif(response == "\xC8"):
|
elif (response == "\xC8"):
|
||||||
packet = PacketListenerManager.handleC8(self.FileObject)
|
packet = PacketListenerManager.handleC8(self.FileObject)
|
||||||
elif(response == "\xC9"):
|
elif (response == "\xC9"):
|
||||||
packet = PacketListenerManager.handleC9(self.FileObject)
|
packet = PacketListenerManager.handleC9(self.FileObject)
|
||||||
elif(response == "\xCA"):
|
elif (response == "\xCA"):
|
||||||
packet = PacketListenerManager.handleCA(self.FileObject)
|
packet = PacketListenerManager.handleCA(self.FileObject)
|
||||||
elif(response == "\xCB"):
|
elif (response == "\xCB"):
|
||||||
packet = PacketListenerManager.handleCB(self.FileObject)
|
packet = PacketListenerManager.handleCB(self.FileObject)
|
||||||
elif(response == "\xFA"):
|
elif (response == "\xFA"):
|
||||||
packet = PacketListenerManager.handleFA(self.FileObject)
|
packet = PacketListenerManager.handleFA(self.FileObject)
|
||||||
elif(response == "\xFC"):
|
elif (response == "\xFC"):
|
||||||
packet = PacketListenerManager.handleFC(self.FileObject)
|
packet = PacketListenerManager.handleFC(self.FileObject)
|
||||||
if (not self.encryptedConnection):
|
if (not self.encryptedConnection):
|
||||||
self.enableEncryption()
|
self.enableEncryption()
|
||||||
self.connection.isConnected = True
|
self.connection.isConnected = True
|
||||||
PacketSenderManager.sendCD(self.socket, 0)
|
PacketSenderManager.sendCD(self.socket, 0)
|
||||||
elif(response == "\xFF"):
|
elif (response == "\xFF"):
|
||||||
packet = PacketListenerManager.handleFF(self.FileObject)
|
packet = PacketListenerManager.handleFF(self.FileObject)
|
||||||
print "Disconnected: " + packet['Reason']
|
print "Disconnected: " + packet['Reason']
|
||||||
self.connection.disconnect()
|
self.connection.disconnect()
|
||||||
|
|||||||
+304
-244
@@ -7,6 +7,7 @@ def handle00(FileObject, socket):
|
|||||||
KAid = DataUtil.readInt(FileObject)
|
KAid = DataUtil.readInt(FileObject)
|
||||||
PacketSenderManager.send00(socket, KAid)
|
PacketSenderManager.send00(socket, KAid)
|
||||||
|
|
||||||
|
|
||||||
def handle01(FileObject):
|
def handle01(FileObject):
|
||||||
Eid = DataUtil.readInt(FileObject)
|
Eid = DataUtil.readInt(FileObject)
|
||||||
world = DataUtil.readString(FileObject)
|
world = DataUtil.readString(FileObject)
|
||||||
@@ -15,78 +16,87 @@ def handle01(FileObject):
|
|||||||
difficulty = DataUtil.readByte(FileObject)
|
difficulty = DataUtil.readByte(FileObject)
|
||||||
FileObject.read(1)
|
FileObject.read(1)
|
||||||
maxplayers = DataUtil.readByte(FileObject)
|
maxplayers = DataUtil.readByte(FileObject)
|
||||||
return {'EntityID' : Eid,
|
return {'EntityID': Eid,
|
||||||
'World' : world,
|
'World': world,
|
||||||
'Mode' : mode,
|
'Mode': mode,
|
||||||
'Dimension' : dimension,
|
'Dimension': dimension,
|
||||||
'Difficulty' : difficulty,
|
'Difficulty': difficulty,
|
||||||
'MaxPlayers' : maxplayers
|
'MaxPlayers': maxplayers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle02(FileObject):
|
def handle02(FileObject):
|
||||||
message = DataUtil.readString(FileObject)
|
message = DataUtil.readString(FileObject)
|
||||||
return message
|
return message
|
||||||
|
|
||||||
|
|
||||||
def handle03(FileObject):
|
def handle03(FileObject):
|
||||||
message = DataUtil.readString(FileObject)
|
message = DataUtil.readString(FileObject)
|
||||||
return {'Message' : message }
|
return {'Message': message}
|
||||||
|
|
||||||
|
|
||||||
def handle04(FileObject):
|
def handle04(FileObject):
|
||||||
time = DataUtil.readLong(FileObject)
|
time = DataUtil.readLong(FileObject)
|
||||||
dayTime = DataUtil.readLong(FileObject)
|
dayTime = DataUtil.readLong(FileObject)
|
||||||
return {'Time' : time,
|
return {'Time': time,
|
||||||
'DayTime' : dayTime
|
'DayTime': dayTime
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle05(FileObject):
|
def handle05(FileObject):
|
||||||
EntityID = DataUtil.readInt(FileObject)
|
EntityID = DataUtil.readInt(FileObject)
|
||||||
Slot = DataUtil.readShort(FileObject)
|
Slot = DataUtil.readShort(FileObject)
|
||||||
Item = DataUtil.readSlotData(FileObject)
|
Item = DataUtil.readSlotData(FileObject)
|
||||||
return {'EntityID' : EntityID,
|
return {'EntityID': EntityID,
|
||||||
'Slot' : Slot,
|
'Slot': Slot,
|
||||||
'Item' : Item
|
'Item': Item
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle06(FileObject):
|
def handle06(FileObject):
|
||||||
x = DataUtil.readInt(FileObject)
|
x = DataUtil.readInt(FileObject)
|
||||||
y = DataUtil.readInt(FileObject)
|
y = DataUtil.readInt(FileObject)
|
||||||
z = DataUtil.readInt(FileObject)
|
z = DataUtil.readInt(FileObject)
|
||||||
return {'x' : x,
|
return {'x': x,
|
||||||
'y' : y,
|
'y': y,
|
||||||
'z' : z
|
'z': z
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle07(FileObject):
|
def handle07(FileObject):
|
||||||
userID = DataUtil.readInt(FileObject)
|
userID = DataUtil.readInt(FileObject)
|
||||||
targetID = DataUtil.readInt(FileObject)
|
targetID = DataUtil.readInt(FileObject)
|
||||||
mButton = DataUtil.readBoolean(FileObject)
|
mButton = DataUtil.readBoolean(FileObject)
|
||||||
return {'userID' : userID,
|
return {'userID': userID,
|
||||||
'targetID' : targetID,
|
'targetID': targetID,
|
||||||
'mButton' : mButton
|
'mButton': mButton
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle08(FileObject):
|
def handle08(FileObject):
|
||||||
health = DataUtil.readShort(FileObject)
|
health = DataUtil.readShort(FileObject)
|
||||||
food = DataUtil.readShort(FileObject)
|
food = DataUtil.readShort(FileObject)
|
||||||
saturation = DataUtil.readFloat(FileObject)
|
saturation = DataUtil.readFloat(FileObject)
|
||||||
return {'health' : health,
|
return {'health': health,
|
||||||
'food' : food,
|
'food': food,
|
||||||
'saturation' : saturation
|
'saturation': saturation
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle09(FileObject):
|
def handle09(FileObject):
|
||||||
dimension = DataUtil.readInt(FileObject)
|
dimension = DataUtil.readInt(FileObject)
|
||||||
difficulty = DataUtil.readByte(FileObject)
|
difficulty = DataUtil.readByte(FileObject)
|
||||||
mode = DataUtil.readByte(FileObject)
|
mode = DataUtil.readByte(FileObject)
|
||||||
height = DataUtil.readShort(FileObject)
|
height = DataUtil.readShort(FileObject)
|
||||||
world = DataUtil.readString(FileObject)
|
world = DataUtil.readString(FileObject)
|
||||||
return {'Dimension' : dimension,
|
return {'Dimension': dimension,
|
||||||
'Difficulty' : difficulty,
|
'Difficulty': difficulty,
|
||||||
'Mode' : mode,
|
'Mode': mode,
|
||||||
'Height' : height,
|
'Height': height,
|
||||||
'World' : world
|
'World': world
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle0D(FileObject):
|
def handle0D(FileObject):
|
||||||
x = DataUtil.readDouble(FileObject)
|
x = DataUtil.readDouble(FileObject)
|
||||||
stance = DataUtil.readDouble(FileObject)
|
stance = DataUtil.readDouble(FileObject)
|
||||||
@@ -95,18 +105,20 @@ def handle0D(FileObject):
|
|||||||
yaw = DataUtil.readFloat(FileObject)
|
yaw = DataUtil.readFloat(FileObject)
|
||||||
pitch = DataUtil.readFloat(FileObject)
|
pitch = DataUtil.readFloat(FileObject)
|
||||||
onGround = DataUtil.readBoolean(FileObject)
|
onGround = DataUtil.readBoolean(FileObject)
|
||||||
return {'x' : x,
|
return {'x': x,
|
||||||
'stance' : stance,
|
'stance': stance,
|
||||||
'y' : y,
|
'y': y,
|
||||||
'z' : z,
|
'z': z,
|
||||||
'yaw' : yaw,
|
'yaw': yaw,
|
||||||
'pitch' : pitch,
|
'pitch': pitch,
|
||||||
'onGround' : onGround
|
'onGround': onGround
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle10(FileObject):
|
def handle10(FileObject):
|
||||||
slotID = DataUtil.readShort(FileObject)
|
slotID = DataUtil.readShort(FileObject)
|
||||||
return {'SlotID' : slotID}
|
return {'SlotID': slotID}
|
||||||
|
|
||||||
|
|
||||||
def handle11(FileObject):
|
def handle11(FileObject):
|
||||||
EntityID = DataUtil.readInt(FileObject)
|
EntityID = DataUtil.readInt(FileObject)
|
||||||
@@ -114,19 +126,21 @@ def handle11(FileObject):
|
|||||||
x = DataUtil.readInt(FileObject)
|
x = DataUtil.readInt(FileObject)
|
||||||
y = DataUtil.readByte(FileObject)
|
y = DataUtil.readByte(FileObject)
|
||||||
z = DataUtil.readInt(FileObject)
|
z = DataUtil.readInt(FileObject)
|
||||||
return {'EntityID' : EntityID,
|
return {'EntityID': EntityID,
|
||||||
'x' : x,
|
'x': x,
|
||||||
'y' : y,
|
'y': y,
|
||||||
'z' : z
|
'z': z
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle12(FileObject):
|
def handle12(FileObject):
|
||||||
EntityID = DataUtil.readInt(FileObject)
|
EntityID = DataUtil.readInt(FileObject)
|
||||||
Animation = DataUtil.readByte(FileObject)
|
Animation = DataUtil.readByte(FileObject)
|
||||||
return {'EntityID' : EntityID,
|
return {'EntityID': EntityID,
|
||||||
'AnimationID' : Animation
|
'AnimationID': Animation
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle14(FileObject):
|
def handle14(FileObject):
|
||||||
EntityID = DataUtil.readInt(FileObject)
|
EntityID = DataUtil.readInt(FileObject)
|
||||||
PlayerName = DataUtil.readString(FileObject)
|
PlayerName = DataUtil.readString(FileObject)
|
||||||
@@ -137,18 +151,19 @@ def handle14(FileObject):
|
|||||||
pitch = DataUtil.readFloat(FileObject)
|
pitch = DataUtil.readFloat(FileObject)
|
||||||
curItem = DataUtil.readShort(FileObject)
|
curItem = DataUtil.readShort(FileObject)
|
||||||
metadata = DataUtil.readEntityMetadata(FileObject)
|
metadata = DataUtil.readEntityMetadata(FileObject)
|
||||||
toReturn = {'EntityID' : EntityID,
|
toReturn = {'EntityID': EntityID,
|
||||||
'Player Name' : PlayerName,
|
'Player Name': PlayerName,
|
||||||
'x' : x,
|
'x': x,
|
||||||
'y' : y,
|
'y': y,
|
||||||
'z' : z,
|
'z': z,
|
||||||
'yaw' : yaw,
|
'yaw': yaw,
|
||||||
'pitch' : pitch,
|
'pitch': pitch,
|
||||||
'curItem' : curItem,
|
'curItem': curItem,
|
||||||
'Metadata' : metadata
|
'Metadata': metadata
|
||||||
}
|
}
|
||||||
return toReturn
|
return toReturn
|
||||||
|
|
||||||
|
|
||||||
def handle15(FileObject):
|
def handle15(FileObject):
|
||||||
EntityID = DataUtil.readInt(FileObject)
|
EntityID = DataUtil.readInt(FileObject)
|
||||||
ItemID = DataUtil.readShort(FileObject)
|
ItemID = DataUtil.readShort(FileObject)
|
||||||
@@ -164,27 +179,29 @@ def handle15(FileObject):
|
|||||||
Rotation = DataUtil.readByte(FileObject)
|
Rotation = DataUtil.readByte(FileObject)
|
||||||
Pitch = DataUtil.readByte(FileObject)
|
Pitch = DataUtil.readByte(FileObject)
|
||||||
Roll = DataUtil.readByte(FileObject)
|
Roll = DataUtil.readByte(FileObject)
|
||||||
toReturn = {'EntityID' : EntityID,
|
toReturn = {'EntityID': EntityID,
|
||||||
'ItemID' : ItemID,
|
'ItemID': ItemID,
|
||||||
'x' : x,
|
'x': x,
|
||||||
'y' : y,
|
'y': y,
|
||||||
'z' : z,
|
'z': z,
|
||||||
'Rotation' : Rotation,
|
'Rotation': Rotation,
|
||||||
'Pitch' : Pitch,
|
'Pitch': Pitch,
|
||||||
'Roll' : Roll
|
'Roll': Roll
|
||||||
}
|
}
|
||||||
if (ItemID != -1):
|
if (ItemID != -1):
|
||||||
toReturn['Count'] = Count
|
toReturn['Count'] = Count
|
||||||
toReturn['Damage'] = Damage
|
toReturn['Damage'] = Damage
|
||||||
return toReturn
|
return toReturn
|
||||||
|
|
||||||
|
|
||||||
def handle16(FileObject):
|
def handle16(FileObject):
|
||||||
CollectedID = DataUtil.readInt(FileObject)
|
CollectedID = DataUtil.readInt(FileObject)
|
||||||
CollectorID = DataUtil.readInt(FileObject)
|
CollectorID = DataUtil.readInt(FileObject)
|
||||||
return {'CollectedID' : CollectedID,
|
return {'CollectedID': CollectedID,
|
||||||
'CollectorID' : CollectorID
|
'CollectorID': CollectorID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle17(FileObject):
|
def handle17(FileObject):
|
||||||
EntityID = DataUtil.readInt(FileObject)
|
EntityID = DataUtil.readInt(FileObject)
|
||||||
Type = DataUtil.readByte(FileObject)
|
Type = DataUtil.readByte(FileObject)
|
||||||
@@ -194,31 +211,32 @@ def handle17(FileObject):
|
|||||||
yaw = DataUtil.readByte(FileObject)
|
yaw = DataUtil.readByte(FileObject)
|
||||||
pitch = DataUtil.readByte(FileObject)
|
pitch = DataUtil.readByte(FileObject)
|
||||||
data = DataUtil.readInt(FileObject)
|
data = DataUtil.readInt(FileObject)
|
||||||
if(data > 0):
|
if (data > 0):
|
||||||
SpeedX = DataUtil.readShort(FileObject)
|
SpeedX = DataUtil.readShort(FileObject)
|
||||||
SpeedY = DataUtil.readShort(FileObject)
|
SpeedY = DataUtil.readShort(FileObject)
|
||||||
SpeedZ = DataUtil.readShort(FileObject)
|
SpeedZ = DataUtil.readShort(FileObject)
|
||||||
return {'EntityID' : EntityID,
|
return {'EntityID': EntityID,
|
||||||
'Type' : Type,
|
'Type': Type,
|
||||||
'x' : x,
|
'x': x,
|
||||||
'y' : y,
|
'y': y,
|
||||||
'z' : z,
|
'z': z,
|
||||||
'yaw' : yaw,
|
'yaw': yaw,
|
||||||
'pitch' : pitch,
|
'pitch': pitch,
|
||||||
'SpeedX' : SpeedX,
|
'SpeedX': SpeedX,
|
||||||
'SpeedY' : SpeedY,
|
'SpeedY': SpeedY,
|
||||||
'SpeedZ' : SpeedZ
|
'SpeedZ': SpeedZ
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
return {'EntityID' : EntityID,
|
return {'EntityID': EntityID,
|
||||||
'Type' : Type,
|
'Type': Type,
|
||||||
'x' : x,
|
'x': x,
|
||||||
'y' : y,
|
'y': y,
|
||||||
'z' : z,
|
'z': z,
|
||||||
'yaw' : yaw,
|
'yaw': yaw,
|
||||||
'pitch' : pitch
|
'pitch': pitch
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle18(FileObject):
|
def handle18(FileObject):
|
||||||
EntityID = DataUtil.readInt(FileObject)
|
EntityID = DataUtil.readInt(FileObject)
|
||||||
Type = DataUtil.readByte(FileObject)
|
Type = DataUtil.readByte(FileObject)
|
||||||
@@ -233,20 +251,21 @@ def handle18(FileObject):
|
|||||||
VelocityZ = DataUtil.readShort(FileObject)
|
VelocityZ = DataUtil.readShort(FileObject)
|
||||||
metadata = DataUtil.readEntityMetadata(FileObject)
|
metadata = DataUtil.readEntityMetadata(FileObject)
|
||||||
|
|
||||||
return {'EntityID' : EntityID,
|
return {'EntityID': EntityID,
|
||||||
'Type' : Type,
|
'Type': Type,
|
||||||
'x' : x,
|
'x': x,
|
||||||
'y' : y,
|
'y': y,
|
||||||
'z' : z,
|
'z': z,
|
||||||
'Yaw' : Yaw,
|
'Yaw': Yaw,
|
||||||
'Pitch' : Pitch,
|
'Pitch': Pitch,
|
||||||
'HeadYaw' : HeadYaw,
|
'HeadYaw': HeadYaw,
|
||||||
'Metadata' : metadata,
|
'Metadata': metadata,
|
||||||
'VelocityX' : VelocityX,
|
'VelocityX': VelocityX,
|
||||||
'VelocityY' : VelocityY,
|
'VelocityY': VelocityY,
|
||||||
'VelocityZ' : VelocityZ
|
'VelocityZ': VelocityZ
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle19(FileObject):
|
def handle19(FileObject):
|
||||||
EntityID = DataUtil.readInt(FileObject)
|
EntityID = DataUtil.readInt(FileObject)
|
||||||
Title = DataUtil.readString(FileObject)
|
Title = DataUtil.readString(FileObject)
|
||||||
@@ -254,38 +273,41 @@ def handle19(FileObject):
|
|||||||
y = DataUtil.readInt(FileObject)
|
y = DataUtil.readInt(FileObject)
|
||||||
z = DataUtil.readInt(FileObject)
|
z = DataUtil.readInt(FileObject)
|
||||||
Direction = DataUtil.readInt(FileObject)
|
Direction = DataUtil.readInt(FileObject)
|
||||||
return {'EntityID' : EntityID,
|
return {'EntityID': EntityID,
|
||||||
'Title' : Title,
|
'Title': Title,
|
||||||
'x' : x,
|
'x': x,
|
||||||
'y' : y,
|
'y': y,
|
||||||
'z' : z,
|
'z': z,
|
||||||
'Direction' : Direction
|
'Direction': Direction
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle1A(FileObject):
|
def handle1A(FileObject):
|
||||||
EntityID = DataUtil.readInt(FileObject)
|
EntityID = DataUtil.readInt(FileObject)
|
||||||
x = DataUtil.readInt(FileObject)
|
x = DataUtil.readInt(FileObject)
|
||||||
y = DataUtil.readInt(FileObject)
|
y = DataUtil.readInt(FileObject)
|
||||||
z = DataUtil.readInt(FileObject)
|
z = DataUtil.readInt(FileObject)
|
||||||
Count = DataUtil.readShort(FileObject)
|
Count = DataUtil.readShort(FileObject)
|
||||||
return {'EntityID' : EntityID,
|
return {'EntityID': EntityID,
|
||||||
'x' : x,
|
'x': x,
|
||||||
'y' : y,
|
'y': y,
|
||||||
'z' : z,
|
'z': z,
|
||||||
'Count' : Count
|
'Count': Count
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle1C(FileObject):
|
def handle1C(FileObject):
|
||||||
EntityID = DataUtil.readInt(FileObject)
|
EntityID = DataUtil.readInt(FileObject)
|
||||||
VelocityX = DataUtil.readShort(FileObject)
|
VelocityX = DataUtil.readShort(FileObject)
|
||||||
VelocityY = DataUtil.readShort(FileObject)
|
VelocityY = DataUtil.readShort(FileObject)
|
||||||
VelocityZ = DataUtil.readShort(FileObject)
|
VelocityZ = DataUtil.readShort(FileObject)
|
||||||
return {'EntityID' : EntityID,
|
return {'EntityID': EntityID,
|
||||||
'VelocityX' : VelocityX,
|
'VelocityX': VelocityX,
|
||||||
'VelocityY' : VelocityY,
|
'VelocityY': VelocityY,
|
||||||
'VelocityZ' : VelocityZ
|
'VelocityZ': VelocityZ
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle1D(FileObject):
|
def handle1D(FileObject):
|
||||||
EntityArrayLength = DataUtil.readByte(FileObject)
|
EntityArrayLength = DataUtil.readByte(FileObject)
|
||||||
Entities = []
|
Entities = []
|
||||||
@@ -293,30 +315,34 @@ def handle1D(FileObject):
|
|||||||
Entities.append(DataUtil.readInt(FileObject))
|
Entities.append(DataUtil.readInt(FileObject))
|
||||||
return Entities
|
return Entities
|
||||||
|
|
||||||
|
|
||||||
def handle1E(FileObject):
|
def handle1E(FileObject):
|
||||||
EntityID = DataUtil.readInt(FileObject)
|
EntityID = DataUtil.readInt(FileObject)
|
||||||
return EntityID
|
return EntityID
|
||||||
|
|
||||||
|
|
||||||
def handle1F(FileObject):
|
def handle1F(FileObject):
|
||||||
EntityID = DataUtil.readInt(FileObject)
|
EntityID = DataUtil.readInt(FileObject)
|
||||||
x = DataUtil.readByte(FileObject)
|
x = DataUtil.readByte(FileObject)
|
||||||
y = DataUtil.readByte(FileObject)
|
y = DataUtil.readByte(FileObject)
|
||||||
z = DataUtil.readByte(FileObject)
|
z = DataUtil.readByte(FileObject)
|
||||||
return {'EntityID' : EntityID,
|
return {'EntityID': EntityID,
|
||||||
'x' : x,
|
'x': x,
|
||||||
'y' : y,
|
'y': y,
|
||||||
'z' : z
|
'z': z
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle20(FileObject):
|
def handle20(FileObject):
|
||||||
EntityID = DataUtil.readInt(FileObject)
|
EntityID = DataUtil.readInt(FileObject)
|
||||||
Yaw = DataUtil.readByte(FileObject)
|
Yaw = DataUtil.readByte(FileObject)
|
||||||
Pitch = DataUtil.readByte(FileObject)
|
Pitch = DataUtil.readByte(FileObject)
|
||||||
return {'EntityID' : EntityID,
|
return {'EntityID': EntityID,
|
||||||
'Yaw' : Yaw,
|
'Yaw': Yaw,
|
||||||
'Pitch' : Pitch
|
'Pitch': Pitch
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle21(FileObject):
|
def handle21(FileObject):
|
||||||
EntityID = DataUtil.readInt(FileObject)
|
EntityID = DataUtil.readInt(FileObject)
|
||||||
x = DataUtil.readByte(FileObject)
|
x = DataUtil.readByte(FileObject)
|
||||||
@@ -324,14 +350,15 @@ def handle21(FileObject):
|
|||||||
z = DataUtil.readByte(FileObject)
|
z = DataUtil.readByte(FileObject)
|
||||||
Yaw = DataUtil.readByte(FileObject)
|
Yaw = DataUtil.readByte(FileObject)
|
||||||
Pitch = DataUtil.readByte(FileObject)
|
Pitch = DataUtil.readByte(FileObject)
|
||||||
return {'EntityID' : EntityID,
|
return {'EntityID': EntityID,
|
||||||
'x' : x,
|
'x': x,
|
||||||
'y' : y,
|
'y': y,
|
||||||
'z' : z,
|
'z': z,
|
||||||
'Yaw' : Yaw,
|
'Yaw': Yaw,
|
||||||
'Pitch' : Pitch
|
'Pitch': Pitch
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle22(FileObject):
|
def handle22(FileObject):
|
||||||
EntityID = DataUtil.readInt(FileObject)
|
EntityID = DataUtil.readInt(FileObject)
|
||||||
x = DataUtil.readInt(FileObject)
|
x = DataUtil.readInt(FileObject)
|
||||||
@@ -339,69 +366,77 @@ def handle22(FileObject):
|
|||||||
z = DataUtil.readInt(FileObject)
|
z = DataUtil.readInt(FileObject)
|
||||||
Yaw = DataUtil.readByte(FileObject)
|
Yaw = DataUtil.readByte(FileObject)
|
||||||
Pitch = DataUtil.readByte(FileObject)
|
Pitch = DataUtil.readByte(FileObject)
|
||||||
return {'EntityID' : EntityID,
|
return {'EntityID': EntityID,
|
||||||
'x' : x,
|
'x': x,
|
||||||
'y' : y,
|
'y': y,
|
||||||
'z' : z,
|
'z': z,
|
||||||
'Yaw' : Yaw,
|
'Yaw': Yaw,
|
||||||
'Pitch' : Pitch
|
'Pitch': Pitch
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle23(FileObject):
|
def handle23(FileObject):
|
||||||
EntityID = DataUtil.readInt(FileObject)
|
EntityID = DataUtil.readInt(FileObject)
|
||||||
HeadYaw = DataUtil.readByte(FileObject)
|
HeadYaw = DataUtil.readByte(FileObject)
|
||||||
return {'EntityID' : EntityID,
|
return {'EntityID': EntityID,
|
||||||
'HeadYaw' : HeadYaw
|
'HeadYaw': HeadYaw
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle26(FileObject):
|
def handle26(FileObject):
|
||||||
EntityID = DataUtil.readInt(FileObject)
|
EntityID = DataUtil.readInt(FileObject)
|
||||||
Status = DataUtil.readByte(FileObject)
|
Status = DataUtil.readByte(FileObject)
|
||||||
return {'EntityID' : EntityID,
|
return {'EntityID': EntityID,
|
||||||
'Status' : Status
|
'Status': Status
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle27(FileObject):
|
def handle27(FileObject):
|
||||||
EntityID = DataUtil.readInt(FileObject)
|
EntityID = DataUtil.readInt(FileObject)
|
||||||
VehicleID = DataUtil.readInt(FileObject)
|
VehicleID = DataUtil.readInt(FileObject)
|
||||||
return {'EntityID' : EntityID,
|
return {'EntityID': EntityID,
|
||||||
'VehicleID' : VehicleID
|
'VehicleID': VehicleID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle28(FileObject):
|
def handle28(FileObject):
|
||||||
EntityID = DataUtil.readInt(FileObject)
|
EntityID = DataUtil.readInt(FileObject)
|
||||||
metadata = DataUtil.readEntityMetadata(FileObject)
|
metadata = DataUtil.readEntityMetadata(FileObject)
|
||||||
return {'EntityID' : EntityID,
|
return {'EntityID': EntityID,
|
||||||
'MetaData' : metadata
|
'MetaData': metadata
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle29(FileObject):
|
def handle29(FileObject):
|
||||||
EntityID = DataUtil.readInt(FileObject)
|
EntityID = DataUtil.readInt(FileObject)
|
||||||
EffectID = DataUtil.readByte(FileObject)
|
EffectID = DataUtil.readByte(FileObject)
|
||||||
Amplifier = DataUtil.readByte(FileObject)
|
Amplifier = DataUtil.readByte(FileObject)
|
||||||
Duration = DataUtil.readShort(FileObject)
|
Duration = DataUtil.readShort(FileObject)
|
||||||
return {'EntityID' : EntityID,
|
return {'EntityID': EntityID,
|
||||||
'EffectID' : EffectID,
|
'EffectID': EffectID,
|
||||||
'Amplifier' : Amplifier,
|
'Amplifier': Amplifier,
|
||||||
'Duration' : Duration
|
'Duration': Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle2A(FileObject):
|
def handle2A(FileObject):
|
||||||
EntityID = DataUtil.readInt(FileObject)
|
EntityID = DataUtil.readInt(FileObject)
|
||||||
EffectID = DataUtil.readByte(FileObject)
|
EffectID = DataUtil.readByte(FileObject)
|
||||||
return {'EntityID' : EntityID,
|
return {'EntityID': EntityID,
|
||||||
'EffectID' : EffectID
|
'EffectID': EffectID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle2B(FileObject):
|
def handle2B(FileObject):
|
||||||
ExperienceBar = DataUtil.readFloat(FileObject)
|
ExperienceBar = DataUtil.readFloat(FileObject)
|
||||||
Level = DataUtil.readShort(FileObject)
|
Level = DataUtil.readShort(FileObject)
|
||||||
TotalExp = DataUtil.readShort(FileObject)
|
TotalExp = DataUtil.readShort(FileObject)
|
||||||
return {'ExpBar' : ExperienceBar,
|
return {'ExpBar': ExperienceBar,
|
||||||
'Level' : Level,
|
'Level': Level,
|
||||||
'TotalExp' : TotalExp
|
'TotalExp': TotalExp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle33(FileObject):
|
def handle33(FileObject):
|
||||||
X = DataUtil.readInt(FileObject)
|
X = DataUtil.readInt(FileObject)
|
||||||
Z = DataUtil.readInt(FileObject)
|
Z = DataUtil.readInt(FileObject)
|
||||||
@@ -410,34 +445,37 @@ def handle33(FileObject):
|
|||||||
AddBitMap = DataUtil.readShort(FileObject)
|
AddBitMap = DataUtil.readShort(FileObject)
|
||||||
CompressedSize = DataUtil.readInt(FileObject)
|
CompressedSize = DataUtil.readInt(FileObject)
|
||||||
FileObject.read(CompressedSize) #not going to be inflating and using this data until I know how to :3
|
FileObject.read(CompressedSize) #not going to be inflating and using this data until I know how to :3
|
||||||
return {'x' : X,
|
return {'x': X,
|
||||||
'z' : Z
|
'z': Z
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle34(FileObject):
|
def handle34(FileObject):
|
||||||
ChunkX = DataUtil.readInt(FileObject)
|
ChunkX = DataUtil.readInt(FileObject)
|
||||||
ChunkZ = DataUtil.readInt(FileObject)
|
ChunkZ = DataUtil.readInt(FileObject)
|
||||||
AffectedBlocks = DataUtil.readShort(FileObject)
|
AffectedBlocks = DataUtil.readShort(FileObject)
|
||||||
DataSize = DataUtil.readInt(FileObject)
|
DataSize = DataUtil.readInt(FileObject)
|
||||||
FileObject.read(DataSize) #not going to be using this until I know how to.
|
FileObject.read(DataSize) #not going to be using this until I know how to.
|
||||||
return {'ChunkX' : ChunkX,
|
return {'ChunkX': ChunkX,
|
||||||
'ChunkZ' : ChunkZ,
|
'ChunkZ': ChunkZ,
|
||||||
'AffectedBlocks' : AffectedBlocks
|
'AffectedBlocks': AffectedBlocks
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle35(FileObject):
|
def handle35(FileObject):
|
||||||
X = DataUtil.readInt(FileObject)
|
X = DataUtil.readInt(FileObject)
|
||||||
Y = DataUtil.readByte(FileObject)
|
Y = DataUtil.readByte(FileObject)
|
||||||
Z = DataUtil.readInt(FileObject)
|
Z = DataUtil.readInt(FileObject)
|
||||||
BlockType = DataUtil.readShort(FileObject)
|
BlockType = DataUtil.readShort(FileObject)
|
||||||
BlockMetaData = DataUtil.readByte(FileObject)
|
BlockMetaData = DataUtil.readByte(FileObject)
|
||||||
return {'x' : X,
|
return {'x': X,
|
||||||
'y' : Y,
|
'y': Y,
|
||||||
'z' : Z,
|
'z': Z,
|
||||||
'BlockType' : BlockType,
|
'BlockType': BlockType,
|
||||||
'MetaData' : BlockMetaData
|
'MetaData': BlockMetaData
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle36(FileObject):
|
def handle36(FileObject):
|
||||||
X = DataUtil.readInt(FileObject)
|
X = DataUtil.readInt(FileObject)
|
||||||
Y = DataUtil.readShort(FileObject)
|
Y = DataUtil.readShort(FileObject)
|
||||||
@@ -445,14 +483,15 @@ def handle36(FileObject):
|
|||||||
Byte1 = DataUtil.readByte(FileObject)
|
Byte1 = DataUtil.readByte(FileObject)
|
||||||
Byte2 = DataUtil.readByte(FileObject)
|
Byte2 = DataUtil.readByte(FileObject)
|
||||||
BlockID = DataUtil.readShort(FileObject)
|
BlockID = DataUtil.readShort(FileObject)
|
||||||
return {'x' : X,
|
return {'x': X,
|
||||||
'y' : Y,
|
'y': Y,
|
||||||
'z' : Z,
|
'z': Z,
|
||||||
'Byte1' : Byte1,
|
'Byte1': Byte1,
|
||||||
'Byte2' : Byte2,
|
'Byte2': Byte2,
|
||||||
'BlockID' : BlockID
|
'BlockID': BlockID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle37(FileObject):
|
def handle37(FileObject):
|
||||||
#int - EntityID
|
#int - EntityID
|
||||||
EntityID = DataUtil.readInt(FileObject)
|
EntityID = DataUtil.readInt(FileObject)
|
||||||
@@ -468,13 +507,14 @@ def handle37(FileObject):
|
|||||||
|
|
||||||
#byte - Stage
|
#byte - Stage
|
||||||
DestroyedStage = DataUtil.readByte(FileObject)
|
DestroyedStage = DataUtil.readByte(FileObject)
|
||||||
return {'EntityID' : EntityID,
|
return {'EntityID': EntityID,
|
||||||
'x' : x,
|
'x': x,
|
||||||
'y' : y,
|
'y': y,
|
||||||
'z' : z,
|
'z': z,
|
||||||
'DestroyedStage' : DestroyedStage
|
'DestroyedStage': DestroyedStage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle38(FileObject):
|
def handle38(FileObject):
|
||||||
#short - number of chunks
|
#short - number of chunks
|
||||||
ChunkCount = DataUtil.readShort(FileObject)
|
ChunkCount = DataUtil.readShort(FileObject)
|
||||||
@@ -488,9 +528,10 @@ def handle38(FileObject):
|
|||||||
for i in range(ChunkCount):
|
for i in range(ChunkCount):
|
||||||
FileObject.read(12)
|
FileObject.read(12)
|
||||||
|
|
||||||
return {'ChunkCount' : ChunkCount
|
return {'ChunkCount': ChunkCount
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle3C(FileObject):
|
def handle3C(FileObject):
|
||||||
X = DataUtil.readDouble(FileObject)
|
X = DataUtil.readDouble(FileObject)
|
||||||
Y = DataUtil.readDouble(FileObject)
|
Y = DataUtil.readDouble(FileObject)
|
||||||
@@ -502,19 +543,20 @@ def handle3C(FileObject):
|
|||||||
x = DataUtil.readByte(FileObject)
|
x = DataUtil.readByte(FileObject)
|
||||||
y = DataUtil.readByte(FileObject)
|
y = DataUtil.readByte(FileObject)
|
||||||
z = DataUtil.readByte(FileObject)
|
z = DataUtil.readByte(FileObject)
|
||||||
AffectedBlocks.append({'x' : x, 'y' : y, 'z' : z})
|
AffectedBlocks.append({'x': x, 'y': y, 'z': z})
|
||||||
#---Unknown what these floats do
|
#---Unknown what these floats do
|
||||||
FileObject.read(4)
|
FileObject.read(4)
|
||||||
FileObject.read(4)
|
FileObject.read(4)
|
||||||
FileObject.read(4)
|
FileObject.read(4)
|
||||||
#---
|
#---
|
||||||
return {'x' : X,
|
return {'x': X,
|
||||||
'y' : Y,
|
'y': Y,
|
||||||
'z' : Z,
|
'z': Z,
|
||||||
'Raidus' : Radius,
|
'Raidus': Radius,
|
||||||
'AffectedBlocks' : AffectedBlocks
|
'AffectedBlocks': AffectedBlocks
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle3D(FileObject):
|
def handle3D(FileObject):
|
||||||
EffectID = DataUtil.readInt(FileObject)
|
EffectID = DataUtil.readInt(FileObject)
|
||||||
X = DataUtil.readInt(FileObject)
|
X = DataUtil.readInt(FileObject)
|
||||||
@@ -522,14 +564,15 @@ def handle3D(FileObject):
|
|||||||
Z = DataUtil.readInt(FileObject)
|
Z = DataUtil.readInt(FileObject)
|
||||||
Data = DataUtil.readInt(FileObject)
|
Data = DataUtil.readInt(FileObject)
|
||||||
NoVolDecrease = DataUtil.readBoolean(FileObject)
|
NoVolDecrease = DataUtil.readBoolean(FileObject)
|
||||||
return {'EffectID' : EffectID,
|
return {'EffectID': EffectID,
|
||||||
'X' : X,
|
'X': X,
|
||||||
'Y' : Y,
|
'Y': Y,
|
||||||
'Z' : Z,
|
'Z': Z,
|
||||||
'Data' : Data,
|
'Data': Data,
|
||||||
'NoVolumeDecrease' : NoVolDecrease
|
'NoVolumeDecrease': NoVolDecrease
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle3E(FileObject):
|
def handle3E(FileObject):
|
||||||
Sound = DataUtil.readString(FileObject)
|
Sound = DataUtil.readString(FileObject)
|
||||||
x = DataUtil.readInt(FileObject)
|
x = DataUtil.readInt(FileObject)
|
||||||
@@ -537,57 +580,63 @@ def handle3E(FileObject):
|
|||||||
z = DataUtil.readInt(FileObject)
|
z = DataUtil.readInt(FileObject)
|
||||||
Volume = DataUtil.readFloat(FileObject)
|
Volume = DataUtil.readFloat(FileObject)
|
||||||
Pitch = DataUtil.readByte(FileObject)
|
Pitch = DataUtil.readByte(FileObject)
|
||||||
return {'Sound' : Sound,
|
return {'Sound': Sound,
|
||||||
'x' : x,
|
'x': x,
|
||||||
'y' : y,
|
'y': y,
|
||||||
'z' : z,
|
'z': z,
|
||||||
'Volume' : Volume,
|
'Volume': Volume,
|
||||||
'Pitch' : Pitch
|
'Pitch': Pitch
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle46(FileObject):
|
def handle46(FileObject):
|
||||||
Reason = DataUtil.readByte(FileObject)
|
Reason = DataUtil.readByte(FileObject)
|
||||||
GameMode = DataUtil.readByte(FileObject)
|
GameMode = DataUtil.readByte(FileObject)
|
||||||
return {'Reason' : Reason,
|
return {'Reason': Reason,
|
||||||
'GameMode' : GameMode
|
'GameMode': GameMode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle47(FileObject):
|
def handle47(FileObject):
|
||||||
EntityID = DataUtil.readInt(FileObject)
|
EntityID = DataUtil.readInt(FileObject)
|
||||||
FileObject.read(1) #Boolean don't do nothing
|
FileObject.read(1) #Boolean don't do nothing
|
||||||
x = DataUtil.readInt(FileObject)
|
x = DataUtil.readInt(FileObject)
|
||||||
y = DataUtil.readInt(FileObject)
|
y = DataUtil.readInt(FileObject)
|
||||||
z = DataUtil.readInt(FileObject)
|
z = DataUtil.readInt(FileObject)
|
||||||
return {'EntityID' : EntityID,
|
return {'EntityID': EntityID,
|
||||||
'x' : x,
|
'x': x,
|
||||||
'y' : y,
|
'y': y,
|
||||||
'z' : z
|
'z': z
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle64(FileObject):
|
def handle64(FileObject):
|
||||||
WindowID = DataUtil.readByte(FileObject)
|
WindowID = DataUtil.readByte(FileObject)
|
||||||
InventoryType = DataUtil.readByte(FileObject)
|
InventoryType = DataUtil.readByte(FileObject)
|
||||||
WindowTitle = DataUtil.readString(FileObject)
|
WindowTitle = DataUtil.readString(FileObject)
|
||||||
NumberOfSlots = DataUtil.readByte(FileObject)
|
NumberOfSlots = DataUtil.readByte(FileObject)
|
||||||
return {'WindowID' : WindowID,
|
return {'WindowID': WindowID,
|
||||||
'InventoryType' : InventoryType,
|
'InventoryType': InventoryType,
|
||||||
'WindowTitle' : WindowTitle,
|
'WindowTitle': WindowTitle,
|
||||||
'NumberOfSlots' : NumberOfSlots
|
'NumberOfSlots': NumberOfSlots
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle65(FileObject):
|
def handle65(FileObject):
|
||||||
WindowID = DataUtil.readByte(FileObject)
|
WindowID = DataUtil.readByte(FileObject)
|
||||||
return WindowID
|
return WindowID
|
||||||
|
|
||||||
|
|
||||||
def handle67(FileObject):
|
def handle67(FileObject):
|
||||||
WindowID = DataUtil.readByte(FileObject)
|
WindowID = DataUtil.readByte(FileObject)
|
||||||
Slot = DataUtil.readShort(FileObject)
|
Slot = DataUtil.readShort(FileObject)
|
||||||
SlotData = DataUtil.readSlotData(FileObject)
|
SlotData = DataUtil.readSlotData(FileObject)
|
||||||
return {'WindowID' : WindowID,
|
return {'WindowID': WindowID,
|
||||||
'Slot' : Slot,
|
'Slot': Slot,
|
||||||
'SlotData' : SlotData
|
'SlotData': SlotData
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle68(FileObject):
|
def handle68(FileObject):
|
||||||
WindowID = DataUtil.readByte(FileObject)
|
WindowID = DataUtil.readByte(FileObject)
|
||||||
Count = DataUtil.readShort(FileObject)
|
Count = DataUtil.readShort(FileObject)
|
||||||
@@ -595,36 +644,40 @@ def handle68(FileObject):
|
|||||||
for i in range(Count):
|
for i in range(Count):
|
||||||
SlotData = DataUtil.readSlotData(FileObject)
|
SlotData = DataUtil.readSlotData(FileObject)
|
||||||
Slots.append(SlotData)
|
Slots.append(SlotData)
|
||||||
return {'WindowID' : WindowID,
|
return {'WindowID': WindowID,
|
||||||
'Count' : Count,
|
'Count': Count,
|
||||||
'Slots' : Slots
|
'Slots': Slots
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle69(FileObject):
|
def handle69(FileObject):
|
||||||
WindowID = DataUtil.readByte(FileObject)
|
WindowID = DataUtil.readByte(FileObject)
|
||||||
Property = DataUtil.readShort(FileObject)
|
Property = DataUtil.readShort(FileObject)
|
||||||
Value = DataUtil.readShort(FileObject)
|
Value = DataUtil.readShort(FileObject)
|
||||||
return {'WindowID' : WindowID,
|
return {'WindowID': WindowID,
|
||||||
'Property' : Property,
|
'Property': Property,
|
||||||
'Value' : Value
|
'Value': Value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle6A(FileObject):
|
def handle6A(FileObject):
|
||||||
WindowID = DataUtil.readByte(FileObject)
|
WindowID = DataUtil.readByte(FileObject)
|
||||||
ActionType = DataUtil.readShort(FileObject)
|
ActionType = DataUtil.readShort(FileObject)
|
||||||
Accepted = DataUtil.readBoolean(FileObject)
|
Accepted = DataUtil.readBoolean(FileObject)
|
||||||
return {'WindowID' : WindowID,
|
return {'WindowID': WindowID,
|
||||||
'ActionType' : ActionType,
|
'ActionType': ActionType,
|
||||||
'Accepted' : Accepted
|
'Accepted': Accepted
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle6B(FileObject):
|
def handle6B(FileObject):
|
||||||
Slot = DataUtil.readShort(FileObject)
|
Slot = DataUtil.readShort(FileObject)
|
||||||
ClickedItem = DataUtil.readSlotData(FileObject)
|
ClickedItem = DataUtil.readSlotData(FileObject)
|
||||||
return {'Slot' : Slot,
|
return {'Slot': Slot,
|
||||||
'ClickedItem' : ClickedItem
|
'ClickedItem': ClickedItem
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle82(FileObject):
|
def handle82(FileObject):
|
||||||
X = DataUtil.readInt(FileObject)
|
X = DataUtil.readInt(FileObject)
|
||||||
Y = DataUtil.readShort(FileObject)
|
Y = DataUtil.readShort(FileObject)
|
||||||
@@ -633,25 +686,27 @@ def handle82(FileObject):
|
|||||||
Line2 = DataUtil.readString(FileObject)
|
Line2 = DataUtil.readString(FileObject)
|
||||||
Line3 = DataUtil.readString(FileObject)
|
Line3 = DataUtil.readString(FileObject)
|
||||||
Line4 = DataUtil.readString(FileObject)
|
Line4 = DataUtil.readString(FileObject)
|
||||||
return {'x' : X,
|
return {'x': X,
|
||||||
'y' : Y,
|
'y': Y,
|
||||||
'z' : Z,
|
'z': Z,
|
||||||
'Line1' : Line1,
|
'Line1': Line1,
|
||||||
'Line2' : Line2,
|
'Line2': Line2,
|
||||||
'Line3' : Line3,
|
'Line3': Line3,
|
||||||
'Line4' : Line4
|
'Line4': Line4
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle83(FileObject):
|
def handle83(FileObject):
|
||||||
ItemType = DataUtil.readShort(FileObject)
|
ItemType = DataUtil.readShort(FileObject)
|
||||||
ItemID = DataUtil.readShort(FileObject)
|
ItemID = DataUtil.readShort(FileObject)
|
||||||
TextLength = DataUtil.readShort(FileObject)
|
TextLength = DataUtil.readShort(FileObject)
|
||||||
Text = DataUtil.readByteArray(FileObject, TextLength)
|
Text = DataUtil.readByteArray(FileObject, TextLength)
|
||||||
return {'ItemType' : ItemType,
|
return {'ItemType': ItemType,
|
||||||
'ItemID' : ItemID,
|
'ItemID': ItemID,
|
||||||
'Text' : Text
|
'Text': Text
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle84(FileObject):
|
def handle84(FileObject):
|
||||||
X = DataUtil.readInt(FileObject)
|
X = DataUtil.readInt(FileObject)
|
||||||
Y = DataUtil.readShort(FileObject)
|
Y = DataUtil.readShort(FileObject)
|
||||||
@@ -661,34 +716,37 @@ def handle84(FileObject):
|
|||||||
if (DataLength != -1):
|
if (DataLength != -1):
|
||||||
ByteArray = DataUtil.readByteArray(FileObject, DataLength)
|
ByteArray = DataUtil.readByteArray(FileObject, DataLength)
|
||||||
NBTData = NBTFile(BytesIO(ByteArray), compression=NBTFile.Compression.GZIP)
|
NBTData = NBTFile(BytesIO(ByteArray), compression=NBTFile.Compression.GZIP)
|
||||||
return {'x' : X,
|
return {'x': X,
|
||||||
'y' : Y,
|
'y': Y,
|
||||||
'z' : Z,
|
'z': Z,
|
||||||
'Action' : Action,
|
'Action': Action,
|
||||||
'NBTData' : NBTData
|
'NBTData': NBTData
|
||||||
}
|
}
|
||||||
return {'x' : X,
|
return {'x': X,
|
||||||
'y' : Y,
|
'y': Y,
|
||||||
'z' : Z,
|
'z': Z,
|
||||||
'Action' : Action
|
'Action': Action
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handleC8(FileObject):
|
def handleC8(FileObject):
|
||||||
StatID = DataUtil.readInt(FileObject)
|
StatID = DataUtil.readInt(FileObject)
|
||||||
Amount = DataUtil.readByte(FileObject)
|
Amount = DataUtil.readByte(FileObject)
|
||||||
return {'StatID' : StatID,
|
return {'StatID': StatID,
|
||||||
'Amount' : Amount
|
'Amount': Amount
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handleC9(FileObject):
|
def handleC9(FileObject):
|
||||||
PlayerName = DataUtil.readString(FileObject)
|
PlayerName = DataUtil.readString(FileObject)
|
||||||
Online = DataUtil.readBoolean(FileObject)
|
Online = DataUtil.readBoolean(FileObject)
|
||||||
Ping = DataUtil.readShort(FileObject)
|
Ping = DataUtil.readShort(FileObject)
|
||||||
return {'PlayerName' : PlayerName,
|
return {'PlayerName': PlayerName,
|
||||||
'Online' : Online,
|
'Online': Online,
|
||||||
'Ping' : Ping
|
'Ping': Ping
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handleCA(FileObject):
|
def handleCA(FileObject):
|
||||||
#byte - flags
|
#byte - flags
|
||||||
Flags = DataUtil.readByte(FileObject)
|
Flags = DataUtil.readByte(FileObject)
|
||||||
@@ -698,25 +756,27 @@ def handleCA(FileObject):
|
|||||||
|
|
||||||
#byte - walk speed
|
#byte - walk speed
|
||||||
WalkSpeed = DataUtil.readByte(FileObject)
|
WalkSpeed = DataUtil.readByte(FileObject)
|
||||||
return {'Flags' : Flags,
|
return {'Flags': Flags,
|
||||||
'Fly Speed' : FlySpeed,
|
'Fly Speed': FlySpeed,
|
||||||
'Walk Speed' : WalkSpeed
|
'Walk Speed': WalkSpeed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handleCB(FileObject):
|
def handleCB(FileObject):
|
||||||
text = DataUtil.readString(FileObject)
|
text = DataUtil.readString(FileObject)
|
||||||
return {'Text' : text}
|
return {'Text': text}
|
||||||
|
|
||||||
|
|
||||||
def handleFA(FileObject):
|
def handleFA(FileObject):
|
||||||
Channel = DataUtil.readString(FileObject)
|
Channel = DataUtil.readString(FileObject)
|
||||||
length = DataUtil.readShort(FileObject)
|
length = DataUtil.readShort(FileObject)
|
||||||
message = DataUtil.readByteArray(FileObject, length)
|
message = DataUtil.readByteArray(FileObject, length)
|
||||||
return {'Channel' : Channel,
|
return {'Channel': Channel,
|
||||||
'message' : message
|
'message': message
|
||||||
}
|
}
|
||||||
|
|
||||||
def handleFC(FileObject):
|
|
||||||
|
|
||||||
|
def handleFC(FileObject):
|
||||||
#short - shared secret length
|
#short - shared secret length
|
||||||
secretLength = DataUtil.readShort(FileObject)
|
secretLength = DataUtil.readShort(FileObject)
|
||||||
|
|
||||||
@@ -727,15 +787,14 @@ def handleFC(FileObject):
|
|||||||
|
|
||||||
token = DataUtil.readByteArray(FileObject, length) #ignore this data, it doesn't matter
|
token = DataUtil.readByteArray(FileObject, length) #ignore this data, it doesn't matter
|
||||||
|
|
||||||
return {'Secret Length' : secretLength,
|
return {'Secret Length': secretLength,
|
||||||
'Shared Secret' : sharedSecret,
|
'Shared Secret': sharedSecret,
|
||||||
'Token Length' : length,
|
'Token Length': length,
|
||||||
'Token' : token
|
'Token': token
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handleFD(FileObject):
|
def handleFD(FileObject):
|
||||||
|
|
||||||
#string - server id
|
#string - server id
|
||||||
serverid = DataUtil.readString(FileObject)
|
serverid = DataUtil.readString(FileObject)
|
||||||
|
|
||||||
@@ -751,11 +810,12 @@ def handleFD(FileObject):
|
|||||||
#byte array - token
|
#byte array - token
|
||||||
token = DataUtil.readByteArray(FileObject, length)
|
token = DataUtil.readByteArray(FileObject, length)
|
||||||
|
|
||||||
return {'ServerID' : serverid,
|
return {'ServerID': serverid,
|
||||||
'Public Key' : pubkey,
|
'Public Key': pubkey,
|
||||||
'Token' : token
|
'Token': token
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handleFF(FileObject):
|
def handleFF(FileObject):
|
||||||
Reason = DataUtil.readString(FileObject)
|
Reason = DataUtil.readString(FileObject)
|
||||||
return {'Reason' : Reason}
|
return {'Reason': Reason}
|
||||||
@@ -7,6 +7,7 @@ def send00(socket, KAid):
|
|||||||
#int - keep alive id
|
#int - keep alive id
|
||||||
DataUtil.sendInt(socket, KAid)
|
DataUtil.sendInt(socket, KAid)
|
||||||
|
|
||||||
|
|
||||||
def sendHandshake(socket, username, host, port):
|
def sendHandshake(socket, username, host, port):
|
||||||
#packet id
|
#packet id
|
||||||
socket.send("\x02")
|
socket.send("\x02")
|
||||||
@@ -23,6 +24,7 @@ def sendHandshake(socket, username, host, port):
|
|||||||
#int - server port
|
#int - server port
|
||||||
DataUtil.sendInt(socket, port)
|
DataUtil.sendInt(socket, port)
|
||||||
|
|
||||||
|
|
||||||
def send03(socket, message):
|
def send03(socket, message):
|
||||||
#packet id
|
#packet id
|
||||||
socket.send("\x03")
|
socket.send("\x03")
|
||||||
@@ -30,6 +32,7 @@ def send03(socket, message):
|
|||||||
#-----string - message-----#
|
#-----string - message-----#
|
||||||
DataUtil.sendString(socket, message)
|
DataUtil.sendString(socket, message)
|
||||||
|
|
||||||
|
|
||||||
def sendCD(socket, payload):
|
def sendCD(socket, payload):
|
||||||
#packet id
|
#packet id
|
||||||
socket.send("\xCD")
|
socket.send("\xCD")
|
||||||
@@ -37,6 +40,7 @@ def sendCD(socket, payload):
|
|||||||
#payload - byte
|
#payload - byte
|
||||||
DataUtil.sendByte(socket, payload)
|
DataUtil.sendByte(socket, payload)
|
||||||
|
|
||||||
|
|
||||||
def sendFC(socket, secret, token):
|
def sendFC(socket, secret, token):
|
||||||
#packet id
|
#packet id
|
||||||
socket.send("\xFC")
|
socket.send("\xFC")
|
||||||
@@ -49,6 +53,7 @@ def sendFC(socket, secret, token):
|
|||||||
DataUtil.sendShort(socket, token.__len__())
|
DataUtil.sendShort(socket, token.__len__())
|
||||||
socket.send(token)
|
socket.send(token)
|
||||||
|
|
||||||
|
|
||||||
def sendFF(socket, reason):
|
def sendFF(socket, reason):
|
||||||
#string - disconnect reason
|
#string - disconnect reason
|
||||||
DataUtil.sendString(socket, reason)
|
DataUtil.sendString(socket, reason)
|
||||||
@@ -2,7 +2,6 @@ import os
|
|||||||
import imp
|
import imp
|
||||||
|
|
||||||
class PluginLoader():
|
class PluginLoader():
|
||||||
|
|
||||||
path = ""
|
path = ""
|
||||||
plugins = []
|
plugins = []
|
||||||
listeners = []
|
listeners = []
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
class IRC:
|
class IRC:
|
||||||
|
|
||||||
options = None
|
options = None
|
||||||
writeFile = None
|
writeFile = None
|
||||||
|
|
||||||
def onEnable(self, parser):
|
def onEnable(self, parser):
|
||||||
|
|
||||||
parser.add_option("-q", "--irc-out-file", dest="ircDump", default="ircdump.txt",
|
parser.add_option("-q", "--irc-out-file", dest="ircDump", default="ircdump.txt",
|
||||||
help="file to dump messages to")
|
help="file to dump messages to")
|
||||||
|
|
||||||
|
|||||||
@@ -2,12 +2,10 @@ import string
|
|||||||
import copy
|
import copy
|
||||||
|
|
||||||
class PacketDumper:
|
class PacketDumper:
|
||||||
|
|
||||||
options = None
|
options = None
|
||||||
writeFile = None
|
writeFile = None
|
||||||
|
|
||||||
def onEnable(self, parser):
|
def onEnable(self, parser):
|
||||||
|
|
||||||
parser.add_option("-d", "--dump-packets",
|
parser.add_option("-d", "--dump-packets",
|
||||||
action="store_true", dest="dumpPackets", default=False,
|
action="store_true", dest="dumpPackets", default=False,
|
||||||
help="run with this argument to dump packets")
|
help="run with this argument to dump packets")
|
||||||
@@ -28,7 +26,7 @@ class PacketDumper:
|
|||||||
packet = copy.deepcopy(receivedPacket)
|
packet = copy.deepcopy(receivedPacket)
|
||||||
if (self.writeFile != None):
|
if (self.writeFile != None):
|
||||||
if (packetID == "\x33" or packetID == "\x38"):
|
if (packetID == "\x33" or packetID == "\x38"):
|
||||||
packet = {'ChunkPlaceHolder' : 0}
|
packet = {'ChunkPlaceHolder': 0}
|
||||||
if (packetID == "\x03"):
|
if (packetID == "\x03"):
|
||||||
packet['Message'] = filter(lambda x: x in string.printable, packet['Message'])
|
packet['Message'] = filter(lambda x: x in string.printable, packet['Message'])
|
||||||
self.writeFile.write(hex(ord(packetID)) + " : " + str(packet) + '\n')
|
self.writeFile.write(hex(ord(packetID)) + " : " + str(packet) + '\n')
|
||||||
|
|||||||
+1
-1
@@ -12,4 +12,4 @@ from pynbt.nbt import (
|
|||||||
TAG_List,
|
TAG_List,
|
||||||
TAG_Compound,
|
TAG_Compound,
|
||||||
TAG_Int_Array
|
TAG_Int_Array
|
||||||
)
|
)
|
||||||
+1
-1
@@ -280,7 +280,7 @@ _tags = (
|
|||||||
TAG_List,
|
TAG_List,
|
||||||
TAG_Compound,
|
TAG_Compound,
|
||||||
TAG_Int_Array
|
TAG_Int_Array
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class NBTFile(TAG_Compound):
|
class NBTFile(TAG_Compound):
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ from networking import PacketSenderManager, NetworkManager
|
|||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
parser = OptionParser()
|
parser = OptionParser()
|
||||||
|
|
||||||
parser.add_option("-u", "--username", dest="username", default="",
|
parser.add_option("-u", "--username", dest="username", default="",
|
||||||
@@ -30,13 +29,13 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
pluginLoader.notifyOptions(options)
|
pluginLoader.notifyOptions(options)
|
||||||
|
|
||||||
if(options.username != ""):
|
if (options.username != ""):
|
||||||
user = options.username
|
user = options.username
|
||||||
else:
|
else:
|
||||||
user = raw_input("Enter your username: ")
|
user = raw_input("Enter your username: ")
|
||||||
if(options.password != ""):
|
if (options.password != ""):
|
||||||
passwd = options.password
|
passwd = options.password
|
||||||
elif(not options.offlineMode):
|
elif (not options.offlineMode):
|
||||||
passwd = getpass.getpass("Enter your password: ")
|
passwd = getpass.getpass("Enter your password: ")
|
||||||
|
|
||||||
if (not options.offlineMode):
|
if (not options.offlineMode):
|
||||||
@@ -44,7 +43,7 @@ if __name__ == "__main__":
|
|||||||
loginThread.start()
|
loginThread.start()
|
||||||
loginThread.join()
|
loginThread.join()
|
||||||
loginResponse = loginThread.getResponse()
|
loginResponse = loginThread.getResponse()
|
||||||
if(loginResponse['Response'] != "Good to go!"):
|
if (loginResponse['Response'] != "Good to go!"):
|
||||||
print loginResponse['Response']
|
print loginResponse['Response']
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
sessionid = loginResponse['SessionID']
|
sessionid = loginResponse['SessionID']
|
||||||
@@ -53,7 +52,7 @@ if __name__ == "__main__":
|
|||||||
else:
|
else:
|
||||||
sessionid = None
|
sessionid = None
|
||||||
|
|
||||||
if(options.server != ""):
|
if (options.server != ""):
|
||||||
serverAddress = options.server
|
serverAddress = options.server
|
||||||
else:
|
else:
|
||||||
serverAddress = raw_input("Enter host and port if any: ")
|
serverAddress = raw_input("Enter host and port if any: ")
|
||||||
|
|||||||
Reference in new issue
Block a user