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