fa21ea7688
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>
59 lines
1.5 KiB
Rust
59 lines
1.5 KiB
Rust
//! The Minecraft Java Edition 26.3 network protocol (protocol version 777):
|
|
//! primitive codecs, framing, compression, encryption, and typed packets for
|
|
//! every connection state, shared by the Horizon client and (later) server.
|
|
#![forbid(unsafe_code)]
|
|
pub mod buf;
|
|
pub mod chunk;
|
|
pub mod connection;
|
|
pub mod crypto;
|
|
pub mod entity_data;
|
|
pub mod frame;
|
|
pub mod ids;
|
|
pub mod item;
|
|
pub mod packets;
|
|
pub mod registry;
|
|
pub mod servers;
|
|
pub mod text;
|
|
|
|
/// SharedConstants.getProtocolVersion() for 26.3.
|
|
pub const PROTOCOL_VERSION: i32 = 777;
|
|
/// The game version servers report in their status.
|
|
pub const GAME_VERSION: &str = "26.3";
|
|
|
|
/// Connection protocol states (ConnectionProtocol).
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
|
pub enum State {
|
|
Handshake,
|
|
Status,
|
|
Login,
|
|
Configuration,
|
|
Play,
|
|
}
|
|
/// PacketFlow.
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
|
pub enum Direction {
|
|
Clientbound,
|
|
Serverbound,
|
|
}
|
|
|
|
/// A malformed or unsupported packet.
|
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
|
pub struct Error(pub String);
|
|
impl Error {
|
|
pub fn new(message: impl Into<String>) -> Self {
|
|
Self(message.into())
|
|
}
|
|
}
|
|
impl std::fmt::Display for Error {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
f.write_str(&self.0)
|
|
}
|
|
}
|
|
impl std::error::Error for Error {}
|
|
impl From<std::io::Error> for Error {
|
|
fn from(e: std::io::Error) -> Self {
|
|
Self(e.to_string())
|
|
}
|
|
}
|
|
pub type Result<T> = std::result::Result<T, Error>;
|