pyCraft/networking/PacketListenerManager.py

749 lines
22 KiB
Python
Raw Normal View History

import DataUtil
import PacketSenderManager
2012-04-05 04:56:21 +02:00
2012-04-15 16:51:00 +02:00
def handle00(FileObject, socket):
KAid = DataUtil.readInt(FileObject)
PacketSenderManager.send00(socket, KAid)
2012-04-15 16:51:00 +02:00
def handle01(FileObject):
Eid = DataUtil.readInt(FileObject)
world = DataUtil.readString(FileObject)
mode = DataUtil.readByte(FileObject)
dimension = DataUtil.readByte(FileObject)
difficulty = DataUtil.readByte(FileObject)
2012-04-15 16:51:00 +02:00
FileObject.read(1)
maxplayers = DataUtil.readByte(FileObject)
return {'EntityID' : Eid,
2012-04-12 00:21:16 +02:00
'World' : world,
'Mode' : mode,
'Dimension' : dimension,
'Difficulty' : difficulty,
'MaxPlayers' : maxplayers
}
2012-04-15 16:51:00 +02:00
def handle02(FileObject):
message = DataUtil.readString(FileObject)
return message
def handle03(FileObject):
message = DataUtil.readString(FileObject)
return {'Message' : message }
2012-04-15 16:51:00 +02:00
def handle04(FileObject):
time = DataUtil.readLong(FileObject)
dayTime = DataUtil.readLong(FileObject)
2012-10-25 20:08:14 +02:00
return {'Time' : time,
'DayTime' : dayTime
}
2012-04-12 00:21:16 +02:00
2012-04-15 16:51:00 +02:00
def handle05(FileObject):
EntityID = DataUtil.readInt(FileObject)
Slot = DataUtil.readShort(FileObject)
Item = DataUtil.readSlotData(FileObject)
2012-04-12 00:21:16 +02:00
return {'EntityID' : EntityID,
'Slot' : Slot,
'Item' : Item
2012-04-12 00:21:16 +02:00
}
2012-04-15 16:51:00 +02:00
def handle06(FileObject):
x = DataUtil.readInt(FileObject)
y = DataUtil.readInt(FileObject)
z = DataUtil.readInt(FileObject)
2012-04-12 00:21:16 +02:00
return {'x' : x,
'y' : y,
'z' : z
}
2012-04-15 16:51:00 +02:00
def handle07(FileObject):
userID = DataUtil.readInt(FileObject)
targetID = DataUtil.readInt(FileObject)
mButton = DataUtil.readBoolean(FileObject)
2012-04-12 00:21:16 +02:00
return {'userID' : userID,
'targetID' : targetID,
'mButton' : mButton
}
2012-04-15 16:51:00 +02:00
def handle08(FileObject):
health = DataUtil.readShort(FileObject)
food = DataUtil.readShort(FileObject)
saturation = DataUtil.readFloat(FileObject)
2012-04-12 00:21:16 +02:00
return {'health' : health,
'food' : food,
'saturation' : saturation
}
2012-04-15 16:51:00 +02:00
def handle09(FileObject):
dimension = DataUtil.readInt(FileObject)
difficulty = DataUtil.readByte(FileObject)
mode = DataUtil.readByte(FileObject)
height = DataUtil.readShort(FileObject)
world = DataUtil.readString(FileObject)
2012-04-12 00:21:16 +02:00
return {'Dimension' : dimension,
'Difficulty' : difficulty,
'Mode' : mode,
'Height' : height,
'World' : world
}
2012-04-15 16:51:00 +02:00
def handle0D(FileObject):
x = DataUtil.readDouble(FileObject)
stance = DataUtil.readDouble(FileObject)
y = DataUtil.readDouble(FileObject)
z = DataUtil.readDouble(FileObject)
yaw = DataUtil.readFloat(FileObject)
pitch = DataUtil.readFloat(FileObject)
onGround = DataUtil.readBoolean(FileObject)
2012-04-12 00:21:16 +02:00
return {'x' : x,
'stance' : stance,
'y' : y,
'z' : z,
'yaw' : yaw,
'pitch' : pitch,
'onGround' : onGround
}
2012-04-15 16:51:00 +02:00
def handle11(FileObject):
EntityID = DataUtil.readInt(FileObject)
2012-04-15 16:51:00 +02:00
FileObject.read(1) #Unused
x = DataUtil.readInt(FileObject)
y = DataUtil.readByte(FileObject)
z = DataUtil.readInt(FileObject)
2012-04-12 00:21:16 +02:00
return {'EntityID' : EntityID,
'x' : x,
'y' : y,
'z' : z
}
2012-04-15 16:51:00 +02:00
def handle12(FileObject):
EntityID = DataUtil.readInt(FileObject)
Animation = DataUtil.readByte(FileObject)
2012-04-12 00:21:16 +02:00
return {'EntityID' : EntityID,
'AnimationID' : Animation
}
2012-04-15 16:51:00 +02:00
def handle14(FileObject):
EntityID = DataUtil.readInt(FileObject)
PlayerName = DataUtil.readString(FileObject)
x = DataUtil.readInt(FileObject)
y = DataUtil.readInt(FileObject)
z = DataUtil.readInt(FileObject)
yaw = DataUtil.readFloat(FileObject)
pitch = DataUtil.readFloat(FileObject)
curItem = DataUtil.readShort(FileObject)
metadata = DataUtil.readEntityMetadata(FileObject)
2012-04-12 00:21:16 +02:00
toReturn = {'EntityID' : EntityID,
'Player Name' : PlayerName,
'x' : x,
'y' : y,
'z' : z,
'yaw' : yaw,
'pitch' : pitch,
'curItem' : curItem,
'Metadata' : metadata
2012-04-12 00:21:16 +02:00
}
return toReturn
2012-04-15 16:51:00 +02:00
def handle15(FileObject):
EntityID = DataUtil.readInt(FileObject)
ItemID = DataUtil.readShort(FileObject)
2012-10-25 20:08:14 +02:00
if (ItemID != -1):
Count = DataUtil.readByte(FileObject)
Damage = DataUtil.readShort(FileObject)
ArrayLength = DataUtil.readShort(FileObject)
2012-10-25 20:08:14 +02:00
if (ArrayLength != -1):
Array = FileObject.read(ArrayLength) #TODO: find out what this does and do stuff accrodingly
x = DataUtil.readInt(FileObject)
y = DataUtil.readInt(FileObject)
z = DataUtil.readInt(FileObject)
Rotation = DataUtil.readByte(FileObject)
Pitch = DataUtil.readByte(FileObject)
Roll = DataUtil.readByte(FileObject)
2012-10-25 20:08:14 +02:00
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
2012-04-12 12:07:25 +02:00
2012-04-15 16:51:00 +02:00
def handle16(FileObject):
CollectedID = DataUtil.readInt(FileObject)
CollectorID = DataUtil.readInt(FileObject)
2012-04-12 12:07:25 +02:00
return {'CollectedID' : CollectedID,
'CollectorID' : CollectorID
}
2012-04-15 16:51:00 +02:00
def handle17(FileObject):
EntityID = DataUtil.readInt(FileObject)
Type = DataUtil.readByte(FileObject)
x = DataUtil.readInt(FileObject)
y = DataUtil.readInt(FileObject)
z = DataUtil.readInt(FileObject)
ThrowerEntityID = DataUtil.readInt(FileObject)
2012-04-12 12:07:25 +02:00
if(ThrowerEntityID > 0):
SpeedX = DataUtil.readShort(FileObject)
SpeedY = DataUtil.readShort(FileObject)
SpeedZ = DataUtil.readShort(FileObject)
2012-04-12 12:07:25 +02:00
return {'EntityID' : EntityID,
'Type' : Type,
'x' : x,
'y' : y,
'z' : z,
'ThrowerEntityID' : ThrowerEntityID,
'SpeedX' : SpeedX,
'SpeedY' : SpeedY,
'SpeedZ' : SpeedZ
}
else:
return {'EntityID' : EntityID,
'Type' : Type,
'x' : x,
'y' : y,
'z' : z,
}
2012-04-15 16:51:00 +02:00
def handle18(FileObject):
EntityID = DataUtil.readInt(FileObject)
Type = DataUtil.readByte(FileObject)
x = DataUtil.readInt(FileObject)
y = DataUtil.readInt(FileObject)
z = DataUtil.readInt(FileObject)
Yaw = DataUtil.readByte(FileObject)
Pitch = DataUtil.readByte(FileObject)
HeadYaw = DataUtil.readByte(FileObject)
VelocityX = DataUtil.readShort(FileObject)
VelocityY = DataUtil.readShort(FileObject)
VelocityZ = DataUtil.readShort(FileObject)
metadata = DataUtil.readEntityMetadata(FileObject)
2012-04-12 12:07:25 +02:00
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
2012-04-12 12:07:25 +02:00
}
2012-04-15 16:51:00 +02:00
def handle19(FileObject):
EntityID = DataUtil.readInt(FileObject)
Title = DataUtil.readString(FileObject)
x = DataUtil.readInt(FileObject)
y = DataUtil.readInt(FileObject)
z = DataUtil.readInt(FileObject)
Direction = DataUtil.readInt(FileObject)
2012-04-12 12:07:25 +02:00
return {'EntityID' : EntityID,
'Title' : Title,
'x' : x,
'y' : y,
'z' : z,
'Direction' : Direction
}
2012-04-15 16:51:00 +02:00
def handle1A(FileObject):
EntityID = DataUtil.readInt(FileObject)
x = DataUtil.readInt(FileObject)
y = DataUtil.readInt(FileObject)
z = DataUtil.readInt(FileObject)
Count = DataUtil.readShort(FileObject)
2012-04-12 12:07:25 +02:00
return {'EntityID' : EntityID,
'x' : x,
'y' : y,
'z' : z,
'Count' : Count
}
2012-04-15 16:51:00 +02:00
def handle1C(FileObject):
EntityID = DataUtil.readInt(FileObject)
VelocityX = DataUtil.readShort(FileObject)
VelocityY = DataUtil.readShort(FileObject)
VelocityZ = DataUtil.readShort(FileObject)
2012-04-12 12:07:25 +02:00
return {'EntityID' : EntityID,
'VelocityX' : VelocityX,
'VelocityY' : VelocityY,
'VelocityZ' : VelocityZ
}
2012-04-15 16:51:00 +02:00
def handle1D(FileObject):
EntityArrayLength = DataUtil.readByte(FileObject)
Entities = []
for i in range(EntityArrayLength):
Entities.append(DataUtil.readInt(FileObject))
return Entities
2012-04-12 12:07:25 +02:00
2012-04-15 16:51:00 +02:00
def handle1E(FileObject):
EntityID = DataUtil.readInt(FileObject)
2012-04-12 12:07:25 +02:00
return EntityID
2012-04-15 16:51:00 +02:00
def handle1F(FileObject):
EntityID = DataUtil.readInt(FileObject)
x = DataUtil.readByte(FileObject)
y = DataUtil.readByte(FileObject)
z = DataUtil.readByte(FileObject)
2012-04-12 12:07:25 +02:00
return {'EntityID' : EntityID,
'x' : x,
'y' : y,
'z' : z
}
2012-04-15 16:51:00 +02:00
def handle20(FileObject):
EntityID = DataUtil.readInt(FileObject)
Yaw = DataUtil.readByte(FileObject)
Pitch = DataUtil.readByte(FileObject)
2012-04-12 12:07:25 +02:00
return {'EntityID' : EntityID,
'Yaw' : Yaw,
'Pitch' : Pitch
}
2012-04-15 16:51:00 +02:00
def handle21(FileObject):
EntityID = DataUtil.readInt(FileObject)
x = DataUtil.readByte(FileObject)
y = DataUtil.readByte(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
}
2012-04-15 16:51:00 +02:00
def handle22(FileObject):
EntityID = DataUtil.readInt(FileObject)
x = DataUtil.readInt(FileObject)
y = DataUtil.readInt(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
}
2012-04-15 16:51:00 +02:00
def handle23(FileObject):
EntityID = DataUtil.readInt(FileObject)
HeadYaw = DataUtil.readByte(FileObject)
return {'EntityID' : EntityID,
'HeadYaw' : HeadYaw
}
2012-04-15 16:51:00 +02:00
def handle26(FileObject):
EntityID = DataUtil.readInt(FileObject)
Status = DataUtil.readByte(FileObject)
return {'EntityID' : EntityID,
'Status' : Status
}
2012-04-15 16:51:00 +02:00
def handle27(FileObject):
EntityID = DataUtil.readInt(FileObject)
VehicleID = DataUtil.readInt(FileObject)
return {'EntityID' : EntityID,
'VehicleID' : VehicleID
}
2012-04-15 16:51:00 +02:00
def handle28(FileObject):
EntityID = DataUtil.readInt(FileObject)
metadata = DataUtil.readEntityMetadata(FileObject)
return {'EntityID' : EntityID,
'MetaData' : metadata
}
2012-04-15 16:51:00 +02:00
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
}
2012-04-15 16:51:00 +02:00
def handle2A(FileObject):
EntityID = DataUtil.readInt(FileObject)
EffectID = DataUtil.readByte(FileObject)
return {'EntityID' : EntityID,
'EffectID' : EffectID
}
2012-04-15 16:51:00 +02:00
def handle2B(FileObject):
ExperienceBar = DataUtil.readFloat(FileObject)
Level = DataUtil.readShort(FileObject)
TotalExp = DataUtil.readShort(FileObject)
return {'ExpBar' : ExperienceBar,
'Level' : Level,
'TotalExp' : TotalExp
}
2012-04-14 17:29:04 +02:00
2012-04-15 16:51:00 +02:00
def handle33(FileObject):
X = DataUtil.readInt(FileObject)
Z = DataUtil.readInt(FileObject)
GroundUpContinous = DataUtil.readBoolean(FileObject)
PrimaryBitMap = DataUtil.readShort(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
2012-04-14 17:29:04 +02:00
return {'x' : X,
'z' : Z
}
2012-04-15 16:51:00 +02:00
def handle34(FileObject):
ChunkX = DataUtil.readInt(FileObject)
ChunkZ = DataUtil.readInt(FileObject)
AffectedBlocks = DataUtil.readShort(FileObject)
DataSize = DataUtil.readInt(FileObject)
2012-04-15 16:51:00 +02:00
FileObject.read(DataSize) #not going to be using this until I know how to.
2012-04-14 17:29:04 +02:00
return {'ChunkX' : ChunkX,
'ChunkZ' : ChunkZ,
'AffectedBlocks' : AffectedBlocks
}
2012-04-15 16:51:00 +02:00
def handle35(FileObject):
X = DataUtil.readInt(FileObject)
Y = DataUtil.readByte(FileObject)
Z = DataUtil.readInt(FileObject)
BlockType = DataUtil.readShort(FileObject)
BlockMetaData = DataUtil.readByte(FileObject)
2012-04-14 17:29:04 +02:00
return {'x' : X,
'y' : Y,
'z' : Z,
'BlockType' : BlockType,
'MetaData' : BlockMetaData
}
2012-04-15 16:51:00 +02:00
def handle36(FileObject):
X = DataUtil.readInt(FileObject)
Y = DataUtil.readShort(FileObject)
Z = DataUtil.readInt(FileObject)
Byte1 = DataUtil.readByte(FileObject)
Byte2 = DataUtil.readByte(FileObject)
BlockID = DataUtil.readShort(FileObject)
2012-04-14 17:29:04 +02:00
return {'x' : X,
'y' : Y,
'z' : Z,
'Byte1' : Byte1,
'Byte2' : Byte2,
'BlockID' : BlockID
}
def handle37(FileObject):
#int - EntityID
EntityID = DataUtil.readInt(FileObject)
#int - X cord
x = DataUtil.readInt(FileObject)
#int - Y cord
y = DataUtil.readInt(FileObject)
#int - Z cord
z = DataUtil.readInt(FileObject)
#byte - Stage
DestroyedStage = DataUtil.readByte(FileObject)
return {'EntityID' : EntityID,
'x' : x,
'y' : y,
'z' : z,
'DestroyedStage' : DestroyedStage
}
def handle38(FileObject):
#short - number of chunks
ChunkCount = DataUtil.readShort(FileObject)
#int - chunk data length
ChunkDataLength = DataUtil.readInt(FileObject)
FileObject.read(ChunkDataLength) #just gonna ignore this for now
#metadata - ignoring this
for i in range(ChunkCount):
FileObject.read(12)
return {'ChunkCount' : ChunkCount
2012-04-14 17:29:04 +02:00
}
2012-04-15 16:51:00 +02:00
def handle3C(FileObject):
X = DataUtil.readDouble(FileObject)
Y = DataUtil.readDouble(FileObject)
Z = DataUtil.readDouble(FileObject)
Radius = DataUtil.readFloat(FileObject)
RecordCount = DataUtil.readInt(FileObject)
2012-04-14 17:29:04 +02:00
AffectedBlocks = []
2012-04-15 16:51:00 +02:00
for i in range((RecordCount * 3)):
x = DataUtil.readByte(FileObject)
y = DataUtil.readByte(FileObject)
z = DataUtil.readByte(FileObject)
2012-04-14 17:29:04 +02:00
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,
2012-04-14 17:29:04 +02:00
'AffectedBlocks' : AffectedBlocks
}
2012-04-15 16:51:00 +02:00
def handle3D(FileObject):
EffectID = DataUtil.readInt(FileObject)
X = DataUtil.readInt(FileObject)
Y = DataUtil.readByte(FileObject)
Z = DataUtil.readInt(FileObject)
Data = DataUtil.readInt(FileObject)
NoVolDecrease = DataUtil.readBoolean(FileObject)
2012-04-14 17:29:04 +02:00
return {'EffectID' : EffectID,
'X' : X,
'Y' : Y,
'Z' : Z,
2012-10-25 20:08:14 +02:00
'Data' : Data,
'NoVolumeDecrease' : NoVolDecrease
2012-04-14 17:29:04 +02:00
}
def handle3E(FileObject):
Sound = DataUtil.readString(FileObject)
x = DataUtil.readInt(FileObject)
y = DataUtil.readInt(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
}
2012-04-15 16:51:00 +02:00
def handle46(FileObject):
Reason = DataUtil.readByte(FileObject)
GameMode = DataUtil.readByte(FileObject)
2012-04-14 17:29:04 +02:00
return {'Reason' : Reason,
'GameMode' : GameMode
}
2012-04-15 16:51:00 +02:00
def handle47(FileObject):
EntityID = DataUtil.readInt(FileObject)
2012-04-15 16:51:00 +02:00
FileObject.read(1) #Boolean don't do nothing
x = DataUtil.readInt(FileObject)
y = DataUtil.readInt(FileObject)
z = DataUtil.readInt(FileObject)
2012-04-14 17:29:04 +02:00
return {'EntityID' : EntityID,
'x' : x,
'y' : y,
'z' : z
}
2012-04-15 16:51:00 +02:00
def handle64(FileObject):
WindowID = DataUtil.readByte(FileObject)
InventoryType = DataUtil.readByte(FileObject)
WindowTitle = DataUtil.readString(FileObject)
NumberOfSlots = DataUtil.readByte(FileObject)
2012-04-14 17:29:04 +02:00
return {'WindowID' : WindowID,
'InventoryType' : InventoryType,
'WindowTitle' : WindowTitle,
'NumberOfSlots' : NumberOfSlots
}
2012-04-15 16:51:00 +02:00
def handle65(FileObject):
WindowID = DataUtil.readByte(FileObject)
2012-04-14 17:29:04 +02:00
return WindowID
2012-04-15 16:51:00 +02:00
def handle67(FileObject):
WindowID = DataUtil.readByte(FileObject)
Slot = DataUtil.readShort(FileObject)
SlotData = DataUtil.readSlotData(FileObject)
2012-04-14 17:29:04 +02:00
return {'WindowID' : WindowID,
'Slot' : Slot,
'SlotData' : SlotData
}
2012-04-15 16:51:00 +02:00
def handle68(FileObject):
WindowID = DataUtil.readByte(FileObject)
Count = DataUtil.readShort(FileObject)
2012-04-15 16:51:00 +02:00
Slots = []
for i in range(Count):
SlotData = DataUtil.readSlotData(FileObject)
2012-04-15 16:51:00 +02:00
Slots.append(SlotData)
2012-04-14 17:29:04 +02:00
return {'WindowID' : WindowID,
'Count' : Count,
2012-04-15 16:51:00 +02:00
'Slots' : Slots
2012-04-14 17:29:04 +02:00
}
2012-04-15 16:51:00 +02:00
def handle69(FileObject):
WindowID = DataUtil.readByte(FileObject)
Property = DataUtil.readShort(FileObject)
Value = DataUtil.readShort(FileObject)
2012-04-14 17:29:04 +02:00
return {'WindowID' : WindowID,
'Property' : Property,
'Value' : Value
}
2012-04-15 16:51:00 +02:00
def handle6A(FileObject):
WindowID = DataUtil.readByte(FileObject)
ActionType = DataUtil.readShort(FileObject)
Accepted = DataUtil.readBoolean(FileObject)
2012-04-14 17:29:04 +02:00
return {'WindowID' : WindowID,
'ActionType' : ActionType,
'Accepted' : Accepted
}
2012-04-15 16:51:00 +02:00
def handle6B(FileObject):
Slot = DataUtil.readShort(FileObject)
ClickedItem = DataUtil.readSlotData(FileObject)
2012-04-14 17:29:04 +02:00
return {'Slot' : Slot,
'ClickedItem' : ClickedItem
}
2012-04-15 16:51:00 +02:00
def handle82(FileObject):
X = DataUtil.readInt(FileObject)
Y = DataUtil.readShort(FileObject)
Z = DataUtil.readInt(FileObject)
Line1 = DataUtil.readString(FileObject)
Line2 = DataUtil.readString(FileObject)
Line3 = DataUtil.readString(FileObject)
Line4 = DataUtil.readString(FileObject)
2012-04-14 17:29:04 +02:00
return {'x' : X,
'y' : Y,
'z' : Z,
'Line1' : Line1,
'Line2' : Line2,
'Line3' : Line3,
'Line4' : Line4
}
2012-04-15 16:51:00 +02:00
def handle83(FileObject):
ItemType = DataUtil.readShort(FileObject)
ItemID = DataUtil.readShort(FileObject)
TextLength = DataUtil.readByte(FileObject)
Text = DataUtil.readByteArray(FileObject, TextLength)
2012-04-14 17:29:04 +02:00
return {'ItemType' : ItemType,
'ItemID' : ItemID,
'Text' : Text
}
2012-04-15 16:51:00 +02:00
def handle84(FileObject):
X = DataUtil.readInt(FileObject)
Y = DataUtil.readShort(FileObject)
Z = DataUtil.readInt(FileObject)
Action = DataUtil.readByte(FileObject)
DataLength = DataUtil.readShort(FileObject)
if (DataLength != -1):
NBTData = DataUtil.readByteArray(FileObject, DataLength)
return {'x' : X,
'y' : Y,
'z' : Z,
'Action' : Action,
'NBTData' : NBTData
}
2012-04-14 17:29:04 +02:00
return {'x' : X,
'y' : Y,
'z' : Z,
'Action' : Action
2012-04-14 17:29:04 +02:00
}
2012-04-15 16:51:00 +02:00
def handleC8(FileObject):
StatID = DataUtil.readInt(FileObject)
Amount = DataUtil.readByte(FileObject)
2012-04-14 17:29:04 +02:00
return {'StatID' : StatID,
'Amount' : Amount
}
2012-04-15 16:51:00 +02:00
def handleC9(FileObject):
PlayerName = DataUtil.readString(FileObject)
Online = DataUtil.readBoolean(FileObject)
Ping = DataUtil.readShort(FileObject)
2012-04-14 17:29:04 +02:00
return {'PlayerName' : PlayerName,
'Online' : Online,
'Ping' : Ping
}
2012-04-15 16:51:00 +02:00
def handleCA(FileObject):
#byte - flags
Flags = DataUtil.readByte(FileObject)
#byte - fly speed
FlySpeed = DataUtil.readByte(FileObject)
#byte - walk speed
WalkSpeed = DataUtil.readByte(FileObject)
return {'Flags' : Flags,
'Fly Speed' : FlySpeed,
'Walk Speed' : WalkSpeed
}
def handleCB(FileObject):
text = DataUtil.readString(FileObject)
return {'Text' : text}
2012-04-15 16:51:00 +02:00
def handleFA(FileObject):
Channel = DataUtil.readString(FileObject)
length = DataUtil.readShort(FileObject)
message = DataUtil.readByteArray(FileObject, length)
return {'Channel' : Channel,
'message' : message
}
def handleFC(FileObject):
#short - shared secret length
secretLength = DataUtil.readShort(FileObject)
sharedSecret = DataUtil.readByteArray(FileObject, secretLength) #ignore this data, it doesn't matter
#short - token length
length = DataUtil.readShort(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
}
def handleFD(FileObject):
#string - server id
serverid = DataUtil.readString(FileObject)
#short - pub key length
length = DataUtil.readShort(FileObject)
#byte array - pub key
pubkey = DataUtil.readByteArray(FileObject, length)
#short - token length
length = DataUtil.readShort(FileObject)
#byte array - token
token = DataUtil.readByteArray(FileObject, length)
return {'ServerID' : serverid,
'Public Key' : pubkey,
'Token' : token
}
2012-04-15 16:51:00 +02:00
def handleFF(FileObject):
Reason = DataUtil.readString(FileObject)
return {'Reason' : Reason}