Update to 1.4 protocol changes

This commit is contained in:
Ammar Askar committed 2012-10-25 23:08:14 +05:00
1 parent 3f9ccce4e2
commit 2a09899634
1 file changed
+30 -18
+30 -18
View File
@@ -37,7 +37,10 @@ def handle03(FileObject):
def handle04(FileObject): def handle04(FileObject):
time = struct.unpack('!q', FileObject.read(8))[0] time = struct.unpack('!q', FileObject.read(8))[0]
return time dayTime = struct.unpack('!q', FileObject.read(8))[0]
return {'Time' : time,
'DayTime' : dayTime
}
def handle05(FileObject): def handle05(FileObject):
EntityID = struct.unpack('!i', FileObject.read(4))[0] EntityID = struct.unpack('!i', FileObject.read(4))[0]
@@ -150,26 +153,32 @@ def handle14(FileObject):
def handle15(FileObject): def handle15(FileObject):
EntityID = struct.unpack('!i', FileObject.read(4))[0] EntityID = struct.unpack('!i', FileObject.read(4))[0]
Item = struct.unpack('!h', FileObject.read(2))[0] ItemID = struct.unpack('!h', FileObject.read(2))[0]
Count = struct.unpack('!b', FileObject.read(1))[0] if (ItemID != -1):
Damage = struct.unpack('!h', FileObject.read(2))[0] Count = struct.unpack('!b', FileObject.read(1))[0]
Damage = struct.unpack('!h', FileObject.read(2))[0]
ArrayLength = struct.unpack('!h', FileObject.read(2))[0]
if (ArrayLength != -1):
Array = FileObject.read(ArrayLength) #TODO: find out what this does and do stuff accrodingly
x = struct.unpack('!i', FileObject.read(4))[0] x = struct.unpack('!i', FileObject.read(4))[0]
y = struct.unpack('!i', FileObject.read(4))[0] y = struct.unpack('!i', FileObject.read(4))[0]
z = struct.unpack('!i', FileObject.read(4))[0] z = struct.unpack('!i', FileObject.read(4))[0]
Rotation = struct.unpack('!b', FileObject.read(1))[0] Rotation = struct.unpack('!b', FileObject.read(1))[0]
Pitch = struct.unpack('!b', FileObject.read(1))[0] Pitch = struct.unpack('!b', FileObject.read(1))[0]
Roll = struct.unpack('!b', FileObject.read(1))[0] Roll = struct.unpack('!b', FileObject.read(1))[0]
return {'EntityID' : EntityID, toReturn = {'EntityID' : EntityID,
'Item' : Item, 'ItemID' : ItemID,
'Count' : Count, 'x' : x,
'Damage' : Damage, 'y' : y,
'x' : x, 'z' : z,
'y' : y, 'Rotation' : Rotation,
'z' : z, 'Pitch' : Pitch,
'Rotation' : Rotation, 'Roll' : Roll
'Pitch' : Pitch, }
'Roll' : Roll if (ItemID != -1):
} toReturn['Count'] = Count
toReturn['Damage'] = Damage
return toReturn
def handle16(FileObject): def handle16(FileObject):
CollectedID = struct.unpack('!i', FileObject.read(4))[0] CollectedID = struct.unpack('!i', FileObject.read(4))[0]
@@ -510,11 +519,13 @@ def handle3D(FileObject):
Y = struct.unpack('!b', FileObject.read(1))[0] Y = struct.unpack('!b', FileObject.read(1))[0]
Z = struct.unpack('!i', FileObject.read(4))[0] Z = struct.unpack('!i', FileObject.read(4))[0]
Data = struct.unpack('!i', FileObject.read(4))[0] Data = struct.unpack('!i', FileObject.read(4))[0]
NoVolDecrease = struct.unpack('?', FileObject.read(1))[0]
return {'EffectID' : EffectID, return {'EffectID' : EffectID,
'X' : X, 'X' : X,
'Y' : Y, 'Y' : Y,
'Z' : Z, 'Z' : Z,
'Data' : Data 'Data' : Data,
'NoVolumeDecrease' : NoVolDecrease
} }
def handle3E(FileObject): def handle3E(FileObject):
@@ -776,8 +787,9 @@ def readEntityMetadata(FileObject):
if ty == 5: if ty == 5:
val = {} val = {}
val["id"] = struct.unpack('!h', FileObject.read(2))[0] val["id"] = struct.unpack('!h', FileObject.read(2))[0]
val["count"] = struct.unpack('!b', FileObject.read(1))[0] if (val["id"] != -1):
val["damage"] = struct.unpack('!h', FileObject.read(2))[0] val["count"] = struct.unpack('!b', FileObject.read(1))[0]
val["damage"] = struct.unpack('!h', FileObject.read(2))[0]
if ty == 6: if ty == 6:
val = [] val = []
for i in range(3): for i in range(3):