Skip to main content

steel_protocol/packets/game/chat/
message.rs

1use std::io::Cursor;
2
3use steel_macros::{ReadFrom, ServerPacket};
4use steel_utils::codec::VarInt;
5
6#[derive(ReadFrom, ServerPacket, Clone, Debug)]
7pub struct SChat {
8    #[read(as = Prefixed(VarInt), bound = 256)]
9    pub message: String,
10
11    pub timestamp: i64,
12
13    pub salt: i64,
14
15    pub signature: Option<[u8; 256]>,
16
17    #[read(as = VarInt)]
18    pub offset: i32,
19
20    pub acknowledged: [u8; 3],
21
22    pub checksum: u8,
23}
24
25/// Client -> Server: Acknowledges messages received from the server.
26///
27/// The client sends this to indicate it has received and processed
28/// messages up to the specified offset.
29///
30/// Equivalent to `ServerboundChatAckPacket` in Minecraft.
31#[derive(ServerPacket, Clone, Debug)]
32pub struct SChatAck {
33    /// The message offset being acknowledged
34    pub offset: VarInt,
35}
36
37impl steel_utils::serial::ReadFrom for SChatAck {
38    fn read(reader: &mut Cursor<&[u8]>) -> std::io::Result<Self> {
39        Ok(Self {
40            offset: VarInt::read(reader)?,
41        })
42    }
43}