Files
horizon-airdef/crates/horizon-protocol/src/packets/status.rs
T
Ludovic Marie fa21ea7688 Add horizon-protocol: the 26.3 network protocol (version 777)
Primitive codecs (VarInt/VarLong, strings, positions, LpVec3, BitSets),
VarInt21 framing, zlib threshold compression, AES/CFB8 encryption, MD5
offline UUIDs, network NBT via horizon-world, item stacks with data
component patches, chunk and light payloads with paletted containers,
synched entity data, and typed packets for every connection state in both
directions with round-trip tests. Packet ids are generated from the data
generator's packets report. The probe example logs into a vanilla 26.3
server and decoded ~8000 packets (329 chunks) without errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 15:13:51 +02:00

51 lines
1.3 KiB
Rust

//! Status state: server list ping.
use crate::{
buf::{Long, Str},
packet, packet_enum,
packets::Empty,
};
packet!(StatusResponse { json: String => Str });
packet!(Ping { time: i64 => Long });
packet_enum!(Clientbound, crate::ids::status::clientbound {
StatusResponse(StatusResponse) = STATUS_RESPONSE,
PongResponse(Ping) = PONG_RESPONSE,
});
packet_enum!(Serverbound, crate::ids::status::serverbound {
StatusRequest(Empty) = STATUS_REQUEST,
PingRequest(Ping) = PING_REQUEST,
});
#[cfg(test)]
mod tests {
use super::*;
use crate::packets::round_trip;
#[test]
fn status_round_trips() {
round_trip(
Clientbound::StatusResponse(StatusResponse {
json: "{\"version\":{}}".into(),
}),
Clientbound::encode,
Clientbound::decode,
);
round_trip(
Clientbound::PongResponse(Ping { time: 123 }),
Clientbound::encode,
Clientbound::decode,
);
round_trip(
Serverbound::StatusRequest(Empty),
Serverbound::encode,
Serverbound::decode,
);
round_trip(
Serverbound::PingRequest(Ping { time: -5 }),
Serverbound::encode,
Serverbound::decode,
);
}
}