📄Cargo.toml
[dependencies]
bedrock-client = { git = "https://github.com/ismaileke/bedrock-client.git", branch = "master" }
tokio = "1.49.0"📄main.rs
use bedrock_client::{client, downcast_bedrock_packet};
use bedrock_client::protocol::bedrock::text::Text;
use std::time::Duration;
use bedrock_client::protocol::bedrock::packet::Packet;
use bedrock_client::protocol::bedrock::play_status::PlayStatus;
use bedrock_client::utils::color_format;
#[tokio::main]
async fn main() {
// Check out my test file for detailed usage
let mut client = client::create(
"127.0.0.1".to_string(), // target address
19132, // target port
"1.26.10".to_string(), // client version
false, // RakNet debug mode
|code, url| {
println!("Microsoft Auth Code: {} - URL: {}", code, url);
}
).await.unwrap();
println!("Client started! Entering game loop...");
loop {
while let Some((packet_name, packet)) = client.next_event() {
println!("[Packet] Received Packet: {}", packet_name);
downcast_bedrock_packet!(packet, PlayStatus, |play_status: &PlayStatus| {
if play_status.status == 3 {
println!("Login Successful! Joined the game.");
let my_text = Text {
text_type: Text::TYPE_CHAT,
needs_translation: false,
source_name: Some("Steve".to_string()),
message: "Hello server!".to_string(),
parameters: None,
xbox_uid: "".to_string(),
platform_chat_id: "".to_string(),
filtered_message: None,
}.encode();
client.send_packet(my_text);
}
});
}
// Logic & Ticking (Prevent 100% CPU usage on Main Thread)
tokio::time::sleep(Duration::from_millis(5)).await;
}
}Note
It is still in development.

