Skip to main content

steel_protocol/packets/common/
c_custom_payload.rs

1use steel_macros::{ClientPacket, WriteTo};
2use steel_registry::packets::config::C_CUSTOM_PAYLOAD;
3use steel_registry::packets::play::C_CUSTOM_PAYLOAD as PLAY_C_CUSTOM_PAYLOAD;
4use steel_utils::Identifier;
5
6#[derive(WriteTo, ClientPacket, Clone, Debug)]
7#[packet_id(Config = C_CUSTOM_PAYLOAD, Play = PLAY_C_CUSTOM_PAYLOAD)]
8pub struct CCustomPayload {
9    pub identifier: Identifier,
10    #[write(as = Prefixed(VarInt))]
11    pub payload: Box<[u8]>,
12}
13
14impl CCustomPayload {
15    #[must_use]
16    pub const fn new(identifier: Identifier, payload: Box<[u8]>) -> Self {
17        Self {
18            identifier,
19            payload,
20        }
21    }
22}