aboutsummaryrefslogtreecommitdiff
path: root/azalea
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2023-02-05 14:31:52 -0600
committermat <github@matdoes.dev>2023-02-05 14:31:52 -0600
commit0d3a091c232d409939db82dfb30f700e57583c85 (patch)
tree592c3734d824fb2a5cc25d07a997c98239b7d99c /azalea
parenta72b76839782b26e49598313bb04c5d322a34788 (diff)
downloadazalea-drasl-0d3a091c232d409939db82dfb30f700e57583c85.tar.xz
improve docs
Diffstat (limited to 'azalea')
-rwxr-xr-xazalea/README.md22
-rw-r--r--azalea/examples/matbot.rs (renamed from azalea/examples/matbot/main.rs)3
-rw-r--r--azalea/src/lib.rs9
3 files changed, 20 insertions, 14 deletions
diff --git a/azalea/README.md b/azalea/README.md
index ef822d9f..ec694d4f 100755
--- a/azalea/README.md
+++ b/azalea/README.md
@@ -37,7 +37,7 @@ opt-level = 3
# Examples
```rust,no_run
-A bot that logs chat messages sent in the server to the console.
+//! A bot that logs chat messages sent in the server to the console.
use azalea::prelude::*;
use parking_lot::Mutex;
@@ -48,15 +48,13 @@ async fn main() {
let account = Account::offline("bot");
// or Account::microsoft("example@example.com").await.unwrap();
- azalea::start(azalea::Options {
- account,
- address: "localhost",
- state: State::default(),
- plugins: plugins![],
- handle,
- })
- .await
- .unwrap();
+ loop {
+ let e = azalea::ClientBuilder::new()
+ .set_handler(handle)
+ .start(account, "localhost")
+ .await;
+ eprintln!("{:?}", e);
+ }
}
#[derive(Default, Clone, Component)]
@@ -76,10 +74,10 @@ async fn handle(bot: Client, event: Event, state: State) -> anyhow::Result<()> {
# Plugins
-Azalea uses [Bevy ECS](https://docs.rs/bevy_ecs) internally to store information about the world and clients. Bevy plugins are more powerful than async handler functions, but more difficult to use. See [pathfinder](azalea/src/pathfinder/mod.rs) as an example of how to make a plugin. You can then use a plugin by adding `.add_plugin(ExamplePlugin)` in the client or swarm builder.
+Azalea uses [Bevy ECS](https://docs.rs/bevy_ecs) internally to store information about the world and clients. Bevy plugins are more powerful than async handler functions, but more difficult to use. See [pathfinder](azalea/src/pathfinder/mod.rs) as an example of how to make a plugin. You can then enable a plugin by adding `.add_plugin(ExamplePlugin)` in your client/swarm builder.
Also note that just because something is an entity in the ECS doesn't mean that it's a Minecraft entity. You can filter for that by having `With<MinecraftEntityId>` as a filter.
-See the [https://bevy-cheatbook.github.io/programming/ecs-intro.html](Bevy Cheatbook) to learn more about Bevy ECS (and ECS in general).
+See the [Bevy Cheatbook](https://bevy-cheatbook.github.io/programming/ecs-intro.html) to learn more about Bevy ECS (and the ECS paradigm in general).
[`azalea_client`]: https://docs.rs/azalea-client \ No newline at end of file
diff --git a/azalea/examples/matbot/main.rs b/azalea/examples/matbot.rs
index a7901929..17736eab 100644
--- a/azalea/examples/matbot/main.rs
+++ b/azalea/examples/matbot.rs
@@ -6,7 +6,6 @@ use azalea::ecs::query::With;
use azalea::entity::metadata::Player;
use azalea::entity::Position;
use azalea::pathfinder::BlockPosGoal;
-// use azalea::ClientInformation;
use azalea::{prelude::*, BlockPos, GameProfileComponent, Swarm, SwarmEvent, WalkDirection};
use azalea::{Account, Client, Event};
use azalea_protocol::packets::game::serverbound_client_command_packet::ServerboundClientCommandPacket;
@@ -66,7 +65,7 @@ async fn main() -> anyhow::Result<()> {
// .set_handler(handle)
// .start(Account::offline("bot"), "localhost")
// .await;
- println!("{e:?}");
+ eprintln!("{e:?}");
}
}
diff --git a/azalea/src/lib.rs b/azalea/src/lib.rs
index 026a35f5..b7707b92 100644
--- a/azalea/src/lib.rs
+++ b/azalea/src/lib.rs
@@ -39,6 +39,15 @@ pub enum StartError {
Join(#[from] azalea_client::JoinError),
}
+/// A builder for creating new [`Client`]s. This is the recommended way of
+/// making Azalea bots.
+///
+/// ```no_run
+/// azalea::ClientBuilder::new()
+/// .set_handler(handle)
+/// .start(Account::offline("bot"), "localhost")
+/// .await;
+/// ```
pub struct ClientBuilder<S, Fut>
where
S: Default + Send + Sync + Clone + 'static,