Provide data to plugins from chunk packets properly
This commit is contained in:
1 parent
d9199a3e2a
commit
83ad822bad
3 files changed
+33
-17
No files matched your search
@@ -16,6 +16,7 @@ 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)
|
||||||
@@ -116,7 +117,6 @@ class ServerConnection(threading.Thread):
|
|||||||
print "Connection to server failed"
|
print "Connection to server failed"
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
class EncryptedFileObjectHandler():
|
class EncryptedFileObjectHandler():
|
||||||
|
|||||||
@@ -440,13 +440,17 @@ def handle2B(FileObject):
|
|||||||
def handle33(FileObject):
|
def handle33(FileObject):
|
||||||
X = DataUtil.readInt(FileObject)
|
X = DataUtil.readInt(FileObject)
|
||||||
Z = DataUtil.readInt(FileObject)
|
Z = DataUtil.readInt(FileObject)
|
||||||
GroundUpContinous = DataUtil.readBoolean(FileObject)
|
GroundUpContinuous = DataUtil.readBoolean(FileObject)
|
||||||
PrimaryBitMap = DataUtil.readShort(FileObject)
|
PrimaryBitMap = DataUtil.readShort(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
|
RawData = FileObject.read(CompressedSize)
|
||||||
return {'x': X,
|
return {'x': X,
|
||||||
'z': Z
|
'z': Z,
|
||||||
|
'GroundUpContinuous': GroundUpContinuous,
|
||||||
|
'PrimaryBitMap': PrimaryBitMap,
|
||||||
|
'AddBitMap': AddBitMap,
|
||||||
|
'RawData': RawData
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -521,14 +525,25 @@ def handle38(FileObject):
|
|||||||
|
|
||||||
#int - chunk data length
|
#int - chunk data length
|
||||||
ChunkDataLength = DataUtil.readInt(FileObject)
|
ChunkDataLength = DataUtil.readInt(FileObject)
|
||||||
DataUtil.readBoolean(FileObject)
|
SkyLightSent = DataUtil.readBoolean(FileObject)
|
||||||
FileObject.read(ChunkDataLength) #just gonna ignore this for now
|
RawData = FileObject.read(ChunkDataLength)
|
||||||
|
|
||||||
#metadata - ignoring this
|
metadata = []
|
||||||
for i in range(ChunkCount):
|
for i in range(ChunkCount):
|
||||||
FileObject.read(12)
|
ChunkX = DataUtil.readInt(FileObject)
|
||||||
|
ChunkZ = DataUtil.readInt(FileObject)
|
||||||
|
PrimaryBitMap = DataUtil.readUnsignedShort(FileObject)
|
||||||
|
AddBitMap = DataUtil.readUnsignedShort(FileObject)
|
||||||
|
metadata.append({'x': ChunkX,
|
||||||
|
'z': ChunkZ,
|
||||||
|
'PrimaryBitMap': PrimaryBitMap,
|
||||||
|
'AddBitMap': AddBitMap
|
||||||
|
})
|
||||||
|
|
||||||
return {'ChunkCount': ChunkCount
|
return {'ChunkCount': ChunkCount,
|
||||||
|
'SkyLightSent': SkyLightSent,
|
||||||
|
'RawData': RawData,
|
||||||
|
'ChunkMeta': metadata
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import string
|
import string
|
||||||
import copy
|
import copy
|
||||||
|
import base64
|
||||||
|
|
||||||
|
|
||||||
class PacketDumper:
|
class PacketDumper:
|
||||||
options = None
|
options = None
|
||||||
@@ -14,21 +16,20 @@ class PacketDumper:
|
|||||||
help="file to dump packets to")
|
help="file to dump packets to")
|
||||||
|
|
||||||
def onDisable(self):
|
def onDisable(self):
|
||||||
if (self.writeFile != None):
|
if self.writeFile is not None:
|
||||||
self.writeFile.close()
|
self.writeFile.close()
|
||||||
|
|
||||||
def optionsParsed(self, parsedOptions):
|
def optionsParsed(self, parsedOptions):
|
||||||
self.options = parsedOptions
|
self.options = parsedOptions
|
||||||
if (self.options.dumpPackets):
|
if self.options.dumpPackets:
|
||||||
self.writeFile = open(self.options.filename, 'w')
|
self.writeFile = open(self.options.filename, 'w')
|
||||||
|
|
||||||
def packetReceive(self, packetID, receivedPacket):
|
def packetReceive(self, packetID, receivedPacket):
|
||||||
packet = copy.deepcopy(receivedPacket)
|
packet = copy.deepcopy(receivedPacket)
|
||||||
if (self.writeFile != None):
|
if self.writeFile is not None:
|
||||||
if (packetID == "\x33" or packetID == "\x38"):
|
if packetID == "\x33" or packetID == "\x38":
|
||||||
packet = {'ChunkPlaceHolder': 0}
|
packet['Data'] = base64.b64encode(packet['RawData'])
|
||||||
if (packetID == "\x03"):
|
del packet['RawData']
|
||||||
|
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')
|
||||||
|
|
||||||
|
|
||||||
Reference in new issue
Block a user