def write_packet(packet): writer = ByteWriter() writer.write_uint32(packet.packet_id) packet.write(writer) return writer.get()
def write(self, writer): data = ByteWriter() data.write_uint32(len(self.items_1)) for item in self.items_1: item.write(data) data.write_uint32(len(self.items_2)) for item in self.items_2: data.write(item) data.write_uint32(len(self.items_3)) for item in self.items_3: data.write(item) data.write_uint32(len(self.items_4)) for item in self.items_4: data.write(item) data.write_uint32(len(self.items_5)) for item in self.items_5: item.write(data) data.write_uint32(len(self.items_6)) for item in self.items_6: data.write(item) data.write_uint32(len(self.items_7)) for item in self.items_7: something, sub_items = item data.write_uint64(something) data.write_uint32(len(sub_items)) for item in sub_items: equipment, d = item equipment.write(data) data.write(d) data.write_uint32(len(self.items_8)) for item in self.items_8: something, sub_items = item data.write_uint64(something) data.write_uint32(len(sub_items)) for item in sub_items: data.write(item) data.write_uint32(len(self.items_9)) for item in self.items_9: entity_id, equipment = item data.write_uint64(entity_id) equipment.write(data) data.write_uint32(len(self.items_10)) for item in self.items_10: entity_id, entity_id2, xp_gained = item data.write_uint64(entity_id) data.write_uint64(entity_id2) data.pad(4) data.write_int32(xp_gained) data.write_uint32(len(self.items_11)) for item in self.items_11: entity_id, target_id, damage = item data.write_uint64(entity_id) data.write_uint64(target_id) data.write_float(damage) data.pad(4) data.write_uint32(len(self.items_12)) for item in self.items_12: data.write(item) data.write_uint32(len(self.items_13)) for item in self.items_13: data.write(item) compressed_data = zlib.compress(data.get()) writer.write_uint32(len(compressed_data)) writer.write(compressed_data)
def set_entity(self, entity, entity_id): writer = ByteWriter() writer.write_uint64(entity_id) write_masked_data(entity, writer) self.data = writer.get()
def write(self, writer): data = ByteWriter() write_list(data, self.items_1) write_list(data, self.items_2) data.write_uint32(len(self.items_3)) for item in self.items_3: data.write(item) write_list(data, self.sound_actions) write_list(data, self.shoot_actions) data.write_uint32(len(self.items_6)) for item in self.items_6: data.write(item) write_list(data, self.items_7) data.write_uint32(len(self.items_8)) for item in self.items_8: something, sub_items = item data.write_uint64(something) data.write_uint32(len(sub_items)) for item in sub_items: data.write(item) write_list(data, self.pickups) write_list(data, self.kill_actions) write_list(data, self.damage_actions) data.write_uint32(len(self.items_12)) for item in self.items_12: data.write(item) data.write_uint32(len(self.items_13)) for item in self.items_13: data.write(item) compressed_data = zlib.compress(data.get()) writer.write_uint32(len(compressed_data)) writer.write(compressed_data)