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_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_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_respawn(fileobj, socket): result = {} result["Dimension"] = data_type_parser.parse_int(fileobj) result["Difficulty"] = mc_datatype.readByte(fileobj) result["GameMode"] = mc_datatype.readByte(fileobj) result["WorldHeight"] = data_type_parser.parse_short(fileobj) result["LevelType"] = mc_datatype.readString(fileobj) return generate_return_data("Respawn",result)
def parse_respawn(fileobj, socket): result = {} result["Dimension"] = data_type_parser.parse_int(fileobj) result["Difficulty"] = mc_datatype.readByte(fileobj) result["GameMode"] = mc_datatype.readByte(fileobj) result["WorldHeight"] = data_type_parser.parse_short(fileobj) result["LevelType"] = mc_datatype.readString(fileobj) return generate_return_data("Respawn", result)
def parse_login_request(fileobj, socket): result = {} result['EntityID'] = mc_datatype.readInt(fileobj) result['LevelType'] = mc_datatype.readString(fileobj) result["GameMode"] = mc_datatype.readByte(fileobj) result["Dimension"] = mc_datatype.readByte(fileobj) result["Difficulty"] = mc_datatype.readByte(fileobj) result["NotUsed"] = mc_datatype.readByte(fileobj) result["MaxPlayers"] = mc_datatype.readByte(fileobj) return generate_return_data("Login_Request",result)
def parse_login_request(fileobj, socket): result = {} result['EntityID'] = mc_datatype.readInt(fileobj) result['LevelType'] = mc_datatype.readString(fileobj) result["GameMode"] = mc_datatype.readByte(fileobj) result["Dimension"] = mc_datatype.readByte(fileobj) result["Difficulty"] = mc_datatype.readByte(fileobj) result["NotUsed"] = mc_datatype.readByte(fileobj) result["MaxPlayers"] = mc_datatype.readByte(fileobj) return generate_return_data("Login_Request", 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_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_named_sound_effect(fileobj, socket): result={} result["SoundName"]=mc_datatype.readString(fileobj) result["EffectPositionX"]=mc_datatype.readInt(fileobj) result["EffectPositionY"]=mc_datatype.readInt(fileobj) result["EffectPositionZ"]=mc_datatype.readInt(fileobj) result["Volume"]=mc_datatype.readFloat(fileobj) result["Pitch"]=mc_datatype.readByte(fileobj) return result
def parse_named_sound_effect(fileobj, socket): result = {} result["SoundName"] = mc_datatype.readString(fileobj) result["EffectPositionX"] = mc_datatype.readInt(fileobj) result["EffectPositionY"] = mc_datatype.readInt(fileobj) result["EffectPositionZ"] = mc_datatype.readInt(fileobj) result["Volume"] = mc_datatype.readFloat(fileobj) result["Pitch"] = mc_datatype.readByte(fileobj) 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_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_destroy_entity(fileobj, socket): # Not fully implemented. Just getting the appropriate packet data. entity_count = mc_datatype.readByte(fileobj) for i in range(entity_count): fileobj.read(4)
def parse_player_abilities(fileobj, socket): result={} result["Flags"]=mc_datatype.readByte(fileobj) result["FlyingSpeed"]=mc_datatype.readFloat(fileobj) result["WalkingSpeed"]=mc_datatype.readFloat(fileobj) return result
def parse_entity_look(fileobj, socket): result = {} result["EntityID"] = mc_datatype.readInt(fileobj) result["Yaw"] = mc_datatype.readByte(fileobj) result["Pitch"] = mc_datatype.readByte(fileobj) 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_change_game_state(fileobj, socket): result={} result["Reason"]=mc_datatype.readByte(fileobj) result["GameMode"]=mc_datatype.readByte(fileobj) return result
def parse_change_game_state(fileobj, socket): result = {} result["Reason"] = mc_datatype.readByte(fileobj) result["GameMode"] = mc_datatype.readByte(fileobj) 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_entity_look(fileobj, socket): result={} result["EntityID"]=mc_datatype.readInt(fileobj) result["Yaw"]=mc_datatype.readByte(fileobj) result["Pitch"]=mc_datatype.readByte(fileobj) return result
def parse_player_abilities(fileobj, socket): result = {} result["Flags"] = mc_datatype.readByte(fileobj) result["FlyingSpeed"] = mc_datatype.readFloat(fileobj) result["WalkingSpeed"] = mc_datatype.readFloat(fileobj) return result