steel_protocol/packets/game/
c_open_sign_editor.rs1use steel_macros::{ClientPacket, WriteTo};
2use steel_registry::packets::play::C_OPEN_SIGN_EDITOR;
3use steel_utils::BlockPos;
4use steel_utils::types::SignTextSlot;
5
6#[derive(ClientPacket, WriteTo, Clone, Debug)]
8#[packet_id(Play = C_OPEN_SIGN_EDITOR)]
9pub struct COpenSignEditor {
10 pub pos: BlockPos,
12 #[write(as = VarInt)]
14 pub slot: SignTextSlot,
15}
16
17#[cfg(test)]
18mod tests {
19 use steel_utils::serial::WriteTo as _;
20
21 use super::*;
22
23 #[test]
24 fn open_sign_editor_writes_slot_as_varint() {
25 let mut bytes = Vec::new();
26 COpenSignEditor {
27 pos: BlockPos::new(0, 64, 0),
28 slot: SignTextSlot::Front,
29 }
30 .write(&mut bytes)
31 .expect("packet should encode");
32
33 assert_eq!(
35 bytes,
36 [&0x0000_0000_0000_0040u64.to_be_bytes()[..], &[1]].concat()
37 );
38 }
39}