steel_protocol/packets/game/
s_sign_update.rs1use std::io::Cursor;
2
3use steel_macros::ServerPacket;
4use steel_utils::BlockPos;
5use steel_utils::serial::{PrefixedRead, ReadFrom};
6
7pub const MAX_SIGN_LINE_LENGTH: usize = 384;
9
10#[derive(ServerPacket, Clone, Debug)]
12pub struct SSignUpdate {
13 pub pos: BlockPos,
15 pub is_front_text: bool,
17 pub lines: [String; 4],
19}
20
21impl ReadFrom for SSignUpdate {
22 fn read(data: &mut Cursor<&[u8]>) -> std::io::Result<Self> {
23 use steel_utils::codec::VarInt;
24
25 let pos = BlockPos::read(data)?;
26 let is_front_text = bool::read(data)?;
27 let lines = [
28 String::read_prefixed_bound::<VarInt>(data, MAX_SIGN_LINE_LENGTH)?,
29 String::read_prefixed_bound::<VarInt>(data, MAX_SIGN_LINE_LENGTH)?,
30 String::read_prefixed_bound::<VarInt>(data, MAX_SIGN_LINE_LENGTH)?,
31 String::read_prefixed_bound::<VarInt>(data, MAX_SIGN_LINE_LENGTH)?,
32 ];
33
34 Ok(Self {
35 pos,
36 is_front_text,
37 lines,
38 })
39 }
40}