1use azalea_buf::AzBuf;
2use azalea_entity::EntityMetadataItems;
3use azalea_protocol_macros::ClientboundGamePacket;
4use azalea_world::MinecraftEntityId;
5
6#[derive(Clone, Debug, AzBuf, PartialEq, ClientboundGamePacket)]
7pub struct ClientboundSetEntityData {
8 #[var]
9 pub id: MinecraftEntityId,
10 pub packed_items: EntityMetadataItems,
11}
12
13#[cfg(test)]
14mod tests {
15 use std::io::Cursor;
16
17 use azalea_buf::AzaleaRead;
18
19 use super::*;
20
21 #[test]
22 fn test_read_hypixel_entity_data_2() {
23 let contents = [
24 161, 21, 2, 6, 0, 5, 8, 0, 6, 21, 0, 7, 1, 0, 1, 1, 172, 2, 3, 8, 0, 4, 8, 0, 9, 1, 0,
25 0, 0, 0, 8, 7, 1, 186, 9, 2, 0, 5, 10, 9, 0, 5, 101, 120, 116, 114, 97, 10, 0, 0, 0, 1,
26 8, 0, 5, 99, 111, 108, 111, 114, 0, 9, 100, 97, 114, 107, 95, 97, 113, 117, 97, 1, 0,
27 4, 98, 111, 108, 100, 1, 8, 0, 4, 116, 101, 120, 116, 0, 18, 67, 108, 111, 117, 100,
28 32, 82, 101, 103, 101, 110, 101, 114, 97, 116, 105, 111, 110, 0, 8, 0, 4, 116, 101,
29 120, 116, 0, 0, 1, 0, 6, 105, 116, 97, 108, 105, 99, 0, 0, 41, 1, 31, 0, 0, 0, 255,
30 ];
31 let mut buf = Cursor::new(contents.as_slice());
32 let packet = ClientboundSetEntityData::azalea_read(&mut buf).unwrap();
33 println!("{packet:?}");
34
35 assert_eq!(buf.position(), contents.len() as u64);
36 }
37
38 #[test]
39 fn test_read_6b6t_entity_data() {
40 let contents = [
41 254, 180, 160, 8, 11, 33, 190, 230, 102, 102, 0, 0, 0, 0, 191, 0, 0, 0, 12, 33, 63,
42 102, 102, 102, 63, 25, 153, 154, 63, 102, 102, 102, 23, 14, 234, 64, 255,
43 ];
44 let mut buf = Cursor::new(contents.as_slice());
45 let packet = ClientboundSetEntityData::azalea_read(&mut buf).unwrap();
46 println!("{packet:?}");
47
48 assert_eq!(buf.position(), contents.len() as u64);
49 }
50}