Skip to main content

terraria_protocol/packets/
sync_monster_type.rs

1use crate::packets::PacketBody;
2use crate::SliceCursor;
3
4/// Sync the type of a cavern monster.
5///
6/// Direction: Client <-> Server.
7#[derive(Debug)]
8pub struct SyncMonsterType {
9    pub net_id: [[u16; 3]; 2],
10}
11
12impl PacketBody for SyncMonsterType {
13    const TAG: u8 = 136;
14
15    fn write_body(&self, cursor: &mut SliceCursor) {
16        self.net_id
17            .iter()
18            .for_each(|row| row.iter().for_each(|x| cursor.write(x)));
19    }
20
21    fn from_body(cursor: &mut SliceCursor) -> Self {
22        Self {
23            net_id: [
24                [cursor.read(), cursor.read(), cursor.read()],
25                [cursor.read(), cursor.read(), cursor.read()],
26            ],
27        }
28    }
29}