pub struct PacketRegistry { /* private fields */ }Expand description
Version-aware packet registry for decoding Minecraft protocol packets.
The registry dispatches raw packet bytes to the correct decoder based on
the packet ID, connection state, and direction (serverbound/clientbound).
It is constructed for a specific protocol version via PacketRegistry::for_version.
Currently supports Handshake, Status, and Login states. Configuration and Play will be added as their packets are generated.
Implementations§
Source§impl PacketRegistry
impl PacketRegistry
Sourcepub fn for_version(version: ProtocolVersion) -> Self
pub fn for_version(version: ProtocolVersion) -> Self
Creates a packet registry for the given protocol version.
Sourcepub fn version(&self) -> ProtocolVersion
pub fn version(&self) -> ProtocolVersion
Returns the protocol version this registry was built for.
Sourcepub fn decode_serverbound_handshake(
&self,
id: i32,
buf: &mut &[u8],
) -> Result<ServerboundHandshakePacket>
pub fn decode_serverbound_handshake( &self, id: i32, buf: &mut &[u8], ) -> Result<ServerboundHandshakePacket>
Decodes a serverbound Handshake packet from its ID and payload.
Sourcepub fn decode_serverbound_status(
&self,
id: i32,
buf: &mut &[u8],
) -> Result<ServerboundStatusPacket>
pub fn decode_serverbound_status( &self, id: i32, buf: &mut &[u8], ) -> Result<ServerboundStatusPacket>
Decodes a serverbound Status packet from its ID and payload.
Sourcepub fn decode_clientbound_status(
&self,
id: i32,
buf: &mut &[u8],
) -> Result<ClientboundStatusPacket>
pub fn decode_clientbound_status( &self, id: i32, buf: &mut &[u8], ) -> Result<ClientboundStatusPacket>
Decodes a clientbound Status packet from its ID and payload.
Sourcepub fn decode_serverbound_login(
&self,
id: i32,
buf: &mut &[u8],
) -> Result<ServerboundLoginPacket>
pub fn decode_serverbound_login( &self, id: i32, buf: &mut &[u8], ) -> Result<ServerboundLoginPacket>
Decodes a serverbound Login packet from its ID and payload.
Sourcepub fn decode_clientbound_login(
&self,
id: i32,
buf: &mut &[u8],
) -> Result<ClientboundLoginPacket>
pub fn decode_clientbound_login( &self, id: i32, buf: &mut &[u8], ) -> Result<ClientboundLoginPacket>
Decodes a clientbound Login packet from its ID and payload.
Sourcepub fn decode_serverbound_configuration(
&self,
id: i32,
buf: &mut &[u8],
) -> Result<ServerboundConfigurationPacket>
pub fn decode_serverbound_configuration( &self, id: i32, buf: &mut &[u8], ) -> Result<ServerboundConfigurationPacket>
Decodes a serverbound Configuration packet from its ID and payload.
Sourcepub fn decode_clientbound_configuration(
&self,
id: i32,
buf: &mut &[u8],
) -> Result<ClientboundConfigurationPacket>
pub fn decode_clientbound_configuration( &self, id: i32, buf: &mut &[u8], ) -> Result<ClientboundConfigurationPacket>
Decodes a clientbound Configuration packet from its ID and payload.
Sourcepub fn decode_serverbound_play(
&self,
id: i32,
buf: &mut &[u8],
) -> Result<ServerboundPlayPacket>
pub fn decode_serverbound_play( &self, id: i32, buf: &mut &[u8], ) -> Result<ServerboundPlayPacket>
Decodes a serverbound Play packet from its ID and payload.
Sourcepub fn decode_clientbound_play(
&self,
id: i32,
buf: &mut &[u8],
) -> Result<ClientboundPlayPacket>
pub fn decode_clientbound_play( &self, id: i32, buf: &mut &[u8], ) -> Result<ClientboundPlayPacket>
Decodes a clientbound Play packet from its ID and payload.