azalea-rs / azalea

A collection of Rust crates for making Minecraft bots, clients, and tools.
https://azalea.matdoes.dev
MIT License
370 stars 47 forks source link

no_handler() option for ClientBuilder #100

Closed TheDudeFromCI closed 1 year ago

TheDudeFromCI commented 1 year ago

The current ClientBuilder implementation fails to compile unless a handler function and state are specified due to the generic values S and Fut of ClientBuilder being unable to resolve. This PR adds placeholder entries and a corresponding no_handler() function for ClientBuilder that allows for a more straightforward implementation when using an exclusively ECS-based codebase.

#[tokio::main]
async fn main() {
    let account = Account::offline("bot");

    let e = ClientBuilder::new()
        .no_handler()
        .add_plugins(...)
        .start(account.clone(), "localhost")
        .await;

    eprintln!("{:?}", e);
}

Note that EmptyState and EmptyFuture must still be public for the code to compile, so I wrapped those in their own module. If needed, they can also be moved to a separate file, but I left them in the lib.rs file so they would remain next to the ClientBuilder.