sandstone is a Minecraft: Java Edition networking library. It is not a server or client implementation, but rather a library that can be used to create your own servers or clients. The ultimate goal is to use this library in a future implementation of a Minecraft: Java Edition server in Rust.
This library currently supports Java Edition v26.3
This project will be a continuous work in progress, and may see months of no activity.
This library is provided as a structured baseline and as an open source software solution for anyone looking to create specialized Minecraft: Java Edition software. It is built with convenient optimizations and abstractions in mind.
This example handles server list status and configures a limit of four concurrent connections per peer IP using sandstone::network::server::CraftListener and std::num::NonZeroUsize.
#[tokio::main]
async fn main() {
SimpleLogger::new().with_level(LevelFilter::Trace).init().unwrap();
debug!("Starting server");
let server = CraftListener::bind("127.0.0.1:25565", NonZeroUsize::new(4).unwrap()).await.unwrap();
loop {
let mut client = server.accept().await.unwrap();
let mut response = StatusResponseSpec::new(ProtocolVerison::latest(), "&a&lThis is a test description &b§kttt");
response.set_player_info(1, 0, vec![PlayerSample::new_random("&6&lTest")]);
let image = image::open("examples/server/status_handler/src/server-icon.png").unwrap();
response.set_favicon_image(image, true).unwrap();
DefaultServerHandshakeHandler::handle_handshake(&mut client).await.unwrap();
DefaultServerStatusHandler::handle_status(&mut client, StatusResponsePacket::new(response), DefaultServerPingHandler)
.await
.unwrap();
}
}More examples can be found in the examples/ folder.
See the extended goals list in the TODO
Please note that this project is under heavy development and functions might not be heavily optimized yet.
Please also note that encryption has not been rigorously tested for security, so please use online features with caution.
- Protocol Wiki = The main resource for implementing new functions for the library. This wiki has extensive documentation on everything relating to the Minecraft protocol, both Bedrock and Java Edition. It also has a lot of articles relating to encryption, the Mojang protocol, and other hidden details about the game.
Some other projects were consulted for general design and handling for the minecraft protocol.
The following projects were significantly useful for understanding some quirks with the Minecraft protocol. It also guided me on early version of McSerializer and McDeserializer (instead of using serde).
