Skip to content

ismaileke/bedrock-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🦀 Bedrock Client

logo

latest release GitHub License GitHub Downloads GitHub Actions Workflow Status

⚙️ Demo

bedrock-client

🧩 Usage

📄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;
use bedrock_client::protocol::bedrock::text::Text;
use std::thread;
use std::time::Duration;

#[tokio::main]
async fn main() {
    // Check out my test file for detailed usage
    let client = client::create(
        "127.0.0.1".to_string(),    // target address
        19132,                      // target port
        "1.21.130".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:{} {}{}", color_format::COLOR_GRAY, color_format::COLOR_MINECOIN_GOLD, color_format::COLOR_GRAY, color_format::COLOR_BLUE, packet_name, color_format::COLOR_GRAY);

            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("ismaileke".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)
        thread::sleep(Duration::from_millis(5));
    }
}

Note

This project is mainly designed for Abyssal Eclipse, but you can get ideas and develop something from the code I wrote. It is still in development. Access to the servers is generally successful.

Packages

No packages published

Contributors 2

  •  
  •  

Languages