1
2
Fork 0
mirror of https://github.com/mat-1/azalea.git synced 2025-08-02 06:16:04 +00:00

improve docs a bit

This commit is contained in:
mat 2023-11-12 17:13:43 -06:00
parent 3d22b5b91c
commit 03cc28d8e7
6 changed files with 27 additions and 17 deletions

View file

@ -122,10 +122,11 @@ impl ChatPacket {
}
impl Client {
/// Sends chat message to the server. This only sends the chat packet and
/// not the command packet. The [`Client::chat`] function handles checking
/// whether the message is a command and using the proper packet for you,
/// so you should use that instead.
/// Send a chat message to the server. This only sends the chat packet and
/// not the command packet, which means on some servers you can use this to
/// send chat messages that start with a `/`. The [`Client::chat`] function
/// handles checking whether the message is a command and using the
/// proper packet for you, so you should use that instead.
pub fn send_chat_packet(&self, message: &str) {
self.ecs.lock().send_event(SendChatKindEvent {
entity: self.entity,

View file

@ -133,7 +133,8 @@ pub enum JoinError {
}
impl Client {
/// Create a new client from the given GameProfile, Connection, and World.
/// Create a new client from the given [`GameProfile`], ECS Entity, ECS
/// World, and schedule runner function.
/// You should only use this if you want to change these fields from the
/// defaults, otherwise use [`Client::join`].
pub fn new(
@ -562,9 +563,9 @@ impl Client {
/// Get the username of this client.
///
/// This is a shortcut for
/// `bot.component::<GameProfileComponent>().name.clone()`.
/// `bot.component::<GameProfileComponent>().name.to_owned()`.
pub fn username(&self) -> String {
self.component::<GameProfileComponent>().name.clone()
self.component::<GameProfileComponent>().name.to_owned()
}
/// Get the Minecraft UUID of this client.

View file

@ -56,6 +56,8 @@ impl Client {
/// }
/// # }
/// ```
///
/// [`Entity`]: bevy_ecs::entity::Entity
pub fn entity_by<F: ReadOnlyWorldQuery, Q: ReadOnlyWorldQuery>(
&mut self,
predicate: impl EntityPredicate<Q, F>,

View file

@ -36,6 +36,8 @@ impl PartialInstance {
/// An entity ID used by Minecraft. These are not guaranteed to be unique in
/// shared worlds, that's what [`Entity`] is for.
///
/// [`Entity`]: bevy_ecs::entity::Entity
#[derive(Component, Copy, Clone, Debug, PartialEq, Eq, Deref, DerefMut)]
pub struct MinecraftEntityId(pub u32);

View file

@ -1,9 +1,7 @@
Azalea is a framework for creating Minecraft bots.
Internally, it's just a wrapper over [`azalea_client`], adding useful
functions for making bots. Because of this, lots of the documentation will
refer to `azalea_client`. You can just replace these with `azalea` in your
code, since everything from azalea_client is re-exported in azalea.
This page is primarily meant for developers that already know they want to use Azalea.
See the [readme](https://github.com/azalea-rs/azalea) for an overview of why you might want to use it.
# Installation
@ -12,10 +10,8 @@ default nightly`.
Then, add one of the following lines to your Cargo.toml:
Latest bleeding-edge version (recommended):
`azalea = { git="https://github.com/azalea-rs/azalea" }`\
Latest "stable" release:
`azalea = "0.8.0"`
- Latest bleeding-edge version (recommended): `azalea = { git="https://github.com/azalea-rs/azalea" }`\
- Latest "stable" release: `azalea = "0.8.0"`
## Optimization
@ -32,6 +28,14 @@ opt-level = 1
[profile.dev.package."*"]
opt-level = 3
```
# Documentation
The documentation for the latest Azalea crates.io release is available at [docs.rs/azalea](https://docs.rs/azalea/latest/azalea/) and the docs for the latest bleeding-edge (git) version are at [azalea.matdoes.dev](https://azalea.matdoes.dev/azalea/).
Note that the `azalea` crate is technically just a wrapper over [`azalea_client`] that adds some extra functions.
Because of this, some of the documentation will refer to `azalea_client`.
You can just replace these with `azalea` in your code since everything from `azalea_client` is re-exported in azalea.
# Examples
@ -73,7 +77,7 @@ async fn handle(bot: Client, event: Event, state: State) -> anyhow::Result<()> {
# Swarms
Azalea lets you create "swarms", which are a group of bots in the same world that can perform actions together. See [testbot](https://github.com/azalea-rs/azalea/blob/main/azalea/examples/testbot.rs) for an example. Also, if you're using swarms, you should also have both `azalea::prelude::*` and `azalea::swarm::prelude::*`.
Azalea lets you create "swarms", which are a group of bots in the same world that can perform actions together. See [testbot](https://github.com/azalea-rs/azalea/blob/main/azalea/examples/testbot.rs) for an example. Also, if you're using swarms, you should also `use` both `azalea::prelude::*` and `azalea::swarm::prelude::*`.
# Plugins

View file

@ -58,9 +58,9 @@ impl Plugin for PathfinderPlugin {
.add_event::<PathFoundEvent>()
.add_event::<StopPathfindingEvent>()
.add_systems(
FixedUpdate,
// putting systems in the FixedUpdate schedule makes them run every Minecraft tick
// (every 50 milliseconds).
FixedUpdate,
(
timeout_movement,
check_node_reached,