def parse_entity_velocity(fileobj, socket): result={} result["EntityID"]=mc_datatype.readInt(fileobj) result["VelocityX"]=mc_datatype.readShort(fileobj) result["VelocityY"]=mc_datatype.readShort(fileobj) result["VelocityZ"]=mc_datatype.readShort(fileobj) return result
def parse_entity_velocity(fileobj, socket): result = {} result["EntityID"] = mc_datatype.readInt(fileobj) result["VelocityX"] = mc_datatype.readShort(fileobj) result["VelocityY"] = mc_datatype.readShort(fileobj) result["VelocityZ"] = mc_datatype.readShort(fileobj) return result
def parse_spawn_object_vehicle(fileobj,socket): FileObject=fileobj EntityID = mc_datatype.readInt(FileObject) Type = mc_datatype.readByte(FileObject) x = mc_datatype.readInt(FileObject) y = mc_datatype.readInt(FileObject) z = mc_datatype.readInt(FileObject) yaw = mc_datatype.readByte(FileObject) pitch = mc_datatype.readByte(FileObject) data = mc_datatype.readInt(FileObject) if (data > 0): SpeedX = mc_datatype.readShort(FileObject) SpeedY = mc_datatype.readShort(FileObject) SpeedZ = mc_datatype.readShort(FileObject) 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 }
def parse_encryption_key_request(fileobj, socket): result={} result["ServerID"]=mc_datatype.readString(fileobj) result["PublicKeyLength"]=mc_datatype.readShort(fileobj) result["PublicKey"]=mc_datatype.readByteArray(fileobj,result["PublicKeyLength"]) result["VerifyTokenLength"]=mc_datatype.readShort(fileobj) result["VerifyToken"]=mc_datatype.readByteArray(fileobj,result["VerifyTokenLength"]) return result
def parse_encryption_key_request(fileobj, socket): result = {} result["ServerID"] = mc_datatype.readString(fileobj) result["PublicKeyLength"] = mc_datatype.readShort(fileobj) result["PublicKey"] = mc_datatype.readByteArray(fileobj, result["PublicKeyLength"]) result["VerifyTokenLength"] = mc_datatype.readShort(fileobj) result["VerifyToken"] = mc_datatype.readByteArray( fileobj, result["VerifyTokenLength"]) return result
def parse_update_tile_entity(fileobj, socket): FileObject = fileobj X = mc_datatype.readInt(FileObject) Y = mc_datatype.readShort(FileObject) Z = mc_datatype.readInt(FileObject) Action = mc_datatype.readByte(FileObject) DataLength = mc_datatype.readShort(FileObject) if (DataLength != -1): ByteArray = mc_datatype.readByteArray(FileObject, DataLength) NBTData = pynbt.NBTFile(io.BytesIO(ByteArray), compression=pynbt.NBTFile.Compression.GZIP) return {'x': X, 'y': Y, 'z': Z, 'Action': Action, 'NBTData': NBTData} return {'x': X, 'y': Y, 'z': Z, 'Action': Action}
def parse_spawn_mob(fileobj,socket): result={} result["EntityID"]=mc_datatype.readInt(fileobj) result["Type"]=mc_datatype.readByte(fileobj) result["X"]=mc_datatype.readInt(fileobj) result["Y"]=mc_datatype.readInt(fileobj) result["Z"]=mc_datatype.readInt(fileobj) result["Pitch"]=mc_datatype.readByte(fileobj) result["HeadPitch"]=mc_datatype.readByte(fileobj) result["Yaw"]=mc_datatype.readByte(fileobj) result["VelocityX"]=mc_datatype.readShort(fileobj) result["VelocityY"]=mc_datatype.readShort(fileobj) result["VelocityZ"]=mc_datatype.readShort(fileobj) result["Metadata"]=mc_datatype.readEntityMetadata(fileobj) return result
def parse_spawn_mob(fileobj, socket): result = {} result["EntityID"] = mc_datatype.readInt(fileobj) result["Type"] = mc_datatype.readByte(fileobj) result["X"] = mc_datatype.readInt(fileobj) result["Y"] = mc_datatype.readInt(fileobj) result["Z"] = mc_datatype.readInt(fileobj) result["Pitch"] = mc_datatype.readByte(fileobj) result["HeadPitch"] = mc_datatype.readByte(fileobj) result["Yaw"] = mc_datatype.readByte(fileobj) result["VelocityX"] = mc_datatype.readShort(fileobj) result["VelocityY"] = mc_datatype.readShort(fileobj) result["VelocityZ"] = mc_datatype.readShort(fileobj) result["Metadata"] = mc_datatype.readEntityMetadata(fileobj) return result
def parse_block_change(fileobj, socket): result={} result["X"]=mc_datatype.readInt(fileobj) result["Y"]=mc_datatype.readByte(fileobj) result["Z"]=mc_datatype.readInt(fileobj) result["BlockType"]=mc_datatype.readShort(fileobj) result["BlockMetadata"]=mc_datatype.readByte(fileobj)
def parse_map_chunk_bulk(fileobj,socket): FileObject=fileobj #short - number of chunks ChunkCount = mc_datatype.readShort(FileObject) #int - chunk data length ChunkDataLength = mc_datatype.readInt(FileObject) SkyLightSent = mc_datatype.readBoolean(FileObject) RawData = FileObject.read(ChunkDataLength) metadata = [] for i in range(ChunkCount): ChunkX = mc_datatype.readInt(FileObject) ChunkZ = mc_datatype.readInt(FileObject) PrimaryBitMap = mc_datatype.readUnsignedShort(FileObject) AddBitMap = mc_datatype.readUnsignedShort(FileObject) metadata.append({'x': ChunkX, 'z': ChunkZ, 'PrimaryBitMap': PrimaryBitMap, 'AddBitMap': AddBitMap }) return {'ChunkCount': ChunkCount, 'SkyLightSent': SkyLightSent, 'RawData': RawData, 'ChunkMeta': metadata }
def parse_map_chunk_bulk(fileobj, socket): FileObject = fileobj #short - number of chunks ChunkCount = mc_datatype.readShort(FileObject) #int - chunk data length ChunkDataLength = mc_datatype.readInt(FileObject) SkyLightSent = mc_datatype.readBoolean(FileObject) RawData = FileObject.read(ChunkDataLength) metadata = [] for i in range(ChunkCount): ChunkX = mc_datatype.readInt(FileObject) ChunkZ = mc_datatype.readInt(FileObject) PrimaryBitMap = mc_datatype.readUnsignedShort(FileObject) AddBitMap = mc_datatype.readUnsignedShort(FileObject) metadata.append({ 'x': ChunkX, 'z': ChunkZ, 'PrimaryBitMap': PrimaryBitMap, 'AddBitMap': AddBitMap }) return { 'ChunkCount': ChunkCount, 'SkyLightSent': SkyLightSent, 'RawData': RawData, 'ChunkMeta': metadata }
def parse_block_change(fileobj, socket): result = {} result["X"] = mc_datatype.readInt(fileobj) result["Y"] = mc_datatype.readByte(fileobj) result["Z"] = mc_datatype.readInt(fileobj) result["BlockType"] = mc_datatype.readShort(fileobj) result["BlockMetadata"] = mc_datatype.readByte(fileobj)
def parse_multi_block_change(fileobj, socket): result = {} result["ChunkX"] = mc_datatype.readInt(fileobj) result["ChunkZ"] = mc_datatype.readInt(fileobj) result["RecordCount"] = mc_datatype.readShort(fileobj) result["DataSize"] = mc_datatype.readInt(fileobj) data = fileobj.read(result["DataSize"]) #Not implemented yet. return result
def parse_multi_block_change(fileobj,socket): result={} result["ChunkX"]=mc_datatype.readInt(fileobj) result["ChunkZ"]=mc_datatype.readInt(fileobj) result["RecordCount"]=mc_datatype.readShort(fileobj) result["DataSize"]=mc_datatype.readInt(fileobj) data = fileobj.read(result["DataSize"]) #Not implemented yet. return result
def parse_set_window_items(fileobj,socket): result={} result["WindowID"]=mc_datatype.readByte(fileobj) result["Count"]=mc_datatype.readShort(fileobj) slots=[] for i in range(result["Count"]): slotdata=mc_datatype.readSlotData(fileobj) slots.append(slotdata) result["Slots"]=slots return result
def parse_set_window_items(fileobj, socket): result = {} result["WindowID"] = mc_datatype.readByte(fileobj) result["Count"] = mc_datatype.readShort(fileobj) slots = [] for i in range(result["Count"]): slotdata = mc_datatype.readSlotData(fileobj) slots.append(slotdata) result["Slots"] = slots return result
def parse_update_tile_entity(fileobj, socket): FileObject=fileobj X = mc_datatype.readInt(FileObject) Y = mc_datatype.readShort(FileObject) Z = mc_datatype.readInt(FileObject) Action = mc_datatype.readByte(FileObject) DataLength = mc_datatype.readShort(FileObject) if (DataLength != -1): ByteArray = mc_datatype.readByteArray(FileObject, DataLength) NBTData = pynbt.NBTFile(io.BytesIO(ByteArray), compression=pynbt.NBTFile.Compression.GZIP) return {'x': X, 'y': Y, 'z': Z, 'Action': Action, 'NBTData': NBTData } return {'x': X, 'y': Y, 'z': Z, 'Action': Action }
def parse_spawn_object_vehicle(fileobj, socket): FileObject = fileobj EntityID = mc_datatype.readInt(FileObject) Type = mc_datatype.readByte(FileObject) x = mc_datatype.readInt(FileObject) y = mc_datatype.readInt(FileObject) z = mc_datatype.readInt(FileObject) yaw = mc_datatype.readByte(FileObject) pitch = mc_datatype.readByte(FileObject) data = mc_datatype.readInt(FileObject) if (data > 0): SpeedX = mc_datatype.readShort(FileObject) SpeedY = mc_datatype.readShort(FileObject) SpeedZ = mc_datatype.readShort(FileObject) 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 }
def parse_entity_properties(FileObject, socket): EntityID = mc_datatype.readInt(FileObject) PropertiesCount = mc_datatype.readInt(FileObject) Properties = {} for i in range(PropertiesCount): key = mc_datatype.readString(FileObject) value = mc_datatype.readDouble(FileObject) Properties[key] = value len = mc_datatype.readShort(FileObject) for x in range(len): uuid_msb = mc_datatype.readLong(FileObject) uuid_lsb = mc_datatype.readLong(FileObject) amount = mc_datatype.readDouble(FileObject) operation = mc_datatype.readByte(FileObject) return {'EntityID': EntityID, 'Properties': Properties}
def parse_entity_properties(FileObject,socket): EntityID = mc_datatype.readInt(FileObject) PropertiesCount = mc_datatype.readInt(FileObject) Properties = {} for i in range(PropertiesCount): key = mc_datatype.readString(FileObject) value = mc_datatype.readDouble(FileObject) Properties[key] = value len = mc_datatype.readShort(FileObject) for x in range(len): uuid_msb = mc_datatype.readLong(FileObject) uuid_lsb = mc_datatype.readLong(FileObject) amount = mc_datatype.readDouble(FileObject) operation = mc_datatype.readByte(FileObject) return {'EntityID': EntityID, 'Properties': Properties }
def parse_set_experience(fileobj, socket): result = {} result["ExperienceBar"] = mc_datatype.readFloat(fileobj) result["Level"] = mc_datatype.readShort(fileobj) result["TotalExp"] = mc_datatype.readShort(fileobj) return result
def parse_plugin_message(fileobj,socket): result={} result["Channel"]=mc_datatype.readString(fileobj) result["Length"]=mc_datatype.readShort(fileobj) result["Data"]=mc_datatype.readByteArray(fileobj,result["Length"]) return result
def parse_set_slot(fileobj, socket): result = {} result["WindowID"] = mc_datatype.readByte(fileobj) result["Slot"] = mc_datatype.readShort(fileobj) result["SlotData"] = mc_datatype.readSlotData(fileobj) return result
def parse_plugin_message(fileobj, socket): result = {} result["Channel"] = mc_datatype.readString(fileobj) result["Length"] = mc_datatype.readShort(fileobj) result["Data"] = mc_datatype.readByteArray(fileobj, result["Length"]) return result
def parse_set_slot(fileobj,socket): result={} result["WindowID"]=mc_datatype.readByte(fileobj) result["Slot"]=mc_datatype.readShort(fileobj) result["SlotData"]=mc_datatype.readSlotData(fileobj) return result
def parse_set_experience(fileobj, socket): result={} result["ExperienceBar"]=mc_datatype.readFloat(fileobj) result["Level"]=mc_datatype.readShort(fileobj) result["TotalExp"]=mc_datatype.readShort(fileobj) return result