aboutsummaryrefslogtreecommitdiff
path: root/azalea
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2023-05-24 02:52:21 -0500
committermat <git@matdoes.dev>2023-05-24 02:52:21 -0500
commit8be3921ad450958ac9bc8c1911ecd65760ea42b6 (patch)
tree2bf05b45f2aaa23f3b1f54c1ef365888ee02f08a /azalea
parent630c78b3180443115b84261a63bfdb3e61c41822 (diff)
parenteb65b0ad6e03f5ffcf8f0f2328ec91bb7e26259f (diff)
downloadazalea-drasl-8be3921ad450958ac9bc8c1911ecd65760ea42b6.tar.xz
merge main
Diffstat (limited to 'azalea')
-rw-r--r--azalea/Cargo.toml25
-rwxr-xr-xazalea/README.md2
-rw-r--r--azalea/src/auto_respawn.rs4
-rw-r--r--azalea/src/lib.rs35
-rw-r--r--azalea/src/pathfinder/mod.rs7
-rw-r--r--azalea/src/pathfinder/moves.rs3
-rw-r--r--azalea/src/swarm/mod.rs41
7 files changed, 93 insertions, 24 deletions
diff --git a/azalea/Cargo.toml b/azalea/Cargo.toml
index 4a7469d3..c03248a7 100644
--- a/azalea/Cargo.toml
+++ b/azalea/Cargo.toml
@@ -4,7 +4,7 @@ edition = "2021"
license = "MIT"
name = "azalea"
repository = "https://github.com/mat-1/azalea/tree/main/azalea"
-version = "0.6.0"
+version = "0.7.0"
[package.metadata.release]
pre-release-replacements = [
@@ -14,17 +14,17 @@ pre-release-replacements = [
[dependencies]
anyhow = "^1.0.65"
async-trait = "0.1.58"
-azalea-block = { version = "0.6.0", path = "../azalea-block" }
-azalea-chat = { version = "0.6.0", path = "../azalea-chat" }
-azalea-client = { version = "0.6.0", path = "../azalea-client" }
-azalea-core = { version = "0.6.0", path = "../azalea-core" }
-azalea-inventory = { version = "0.1.0", path = "../azalea-inventory" }
-azalea-physics = { version = "0.6.0", path = "../azalea-physics" }
-azalea-protocol = { version = "0.6.0", path = "../azalea-protocol" }
-azalea-registry = { version = "0.6.0", path = "../azalea-registry" }
-azalea-world = { version = "0.6.0", path = "../azalea-world" }
-azalea-auth = { version = "0.6.0", path = "../azalea-auth" }
-azalea-brigadier = { version = "0.6.0", path = "../azalea-brigadier" }
+azalea-block = { version = "0.7.0", path = "../azalea-block" }
+azalea-chat = { version = "0.7.0", path = "../azalea-chat" }
+azalea-client = { version = "0.7.0", path = "../azalea-client" }
+azalea-core = { version = "0.7.0", path = "../azalea-core" }
+azalea-inventory = { version = "0.7.0", path = "../azalea-inventory" }
+azalea-physics = { version = "0.7.0", path = "../azalea-physics" }
+azalea-protocol = { version = "0.7.0", path = "../azalea-protocol" }
+azalea-registry = { version = "0.7.0", path = "../azalea-registry" }
+azalea-world = { version = "0.7.0", path = "../azalea-world" }
+azalea-auth = { version = "0.7.0", path = "../azalea-auth" }
+azalea-brigadier = { version = "0.7.0", path = "../azalea-brigadier" }
bevy_app = "0.10.0"
bevy_ecs = "0.10.0"
bevy_tasks = "0.10.0"
@@ -39,3 +39,4 @@ priority-queue = "1.3.0"
thiserror = "^1.0.37"
tokio = "^1.24.2"
uuid = "1.2.2"
+bevy_log = "0.10.1"
diff --git a/azalea/README.md b/azalea/README.md
index 21be566a..e173bdd2 100755
--- a/azalea/README.md
+++ b/azalea/README.md
@@ -15,7 +15,7 @@ Then, add one of the following lines to your Cargo.toml:
Latest bleeding-edge version:
`azalea = { git="https://github.com/mat-1/azalea" }`\
Latest "stable" release:
-`azalea = "0.6.0"`
+`azalea = "0.7.0"`
## Optimization
diff --git a/azalea/src/auto_respawn.rs b/azalea/src/auto_respawn.rs
index c5dd12a4..d2973a2f 100644
--- a/azalea/src/auto_respawn.rs
+++ b/azalea/src/auto_respawn.rs
@@ -1,6 +1,6 @@
use crate::app::{App, Plugin};
use azalea_client::packet_handling::DeathEvent;
-use azalea_client::respawn::PerformRespawnEvent;
+use azalea_client::respawn::{perform_respawn, PerformRespawnEvent};
use bevy_ecs::prelude::*;
/// A plugin that makes [`DeathEvent`]s send [`PerformRespawnEvent`]s.
@@ -8,7 +8,7 @@ use bevy_ecs::prelude::*;
pub struct AutoRespawnPlugin;
impl Plugin for AutoRespawnPlugin {
fn build(&self, app: &mut App) {
- app.add_system(auto_respawn);
+ app.add_system(auto_respawn.before(perform_respawn));
}
}
diff --git a/azalea/src/lib.rs b/azalea/src/lib.rs
index 604961f4..fd735585 100644
--- a/azalea/src/lib.rs
+++ b/azalea/src/lib.rs
@@ -14,12 +14,13 @@ use app::{App, Plugin, PluginGroup};
pub use azalea_auth as auth;
pub use azalea_block as blocks;
pub use azalea_brigadier as brigadier;
+pub use azalea_chat::FormattedText;
pub use azalea_client::*;
pub use azalea_core::{BlockPos, Vec3};
pub use azalea_protocol as protocol;
pub use azalea_registry::{Block, EntityKind, Item};
pub use azalea_world::{entity, Instance};
-use bot::DefaultBotPlugins;
+pub use bot::DefaultBotPlugins;
use ecs::component::Component;
use futures::Future;
use protocol::{
@@ -80,16 +81,42 @@ where
/// Start building a client that can join the world.
#[must_use]
pub fn new() -> Self {
+ Self::new_without_plugins()
+ .add_plugins(DefaultPlugins)
+ .add_plugins(DefaultBotPlugins)
+ }
+
+ /// [`Self::new`] but without adding the plugins by default. This is useful
+ /// if you want to disable a default plugin.
+ ///
+ /// You **must** add [`DefaultPlugins`] and [`DefaultBotPlugins`] to this.
+ ///
+ /// ```
+ /// # use azalea::prelude::*;
+ /// use azalea::{app::PluginGroup, DefaultBotPlugins, DefaultPlugins};
+ /// use bevy_log::LogPlugin;
+ ///
+ /// let client_builder = ClientBuilder::new_without_plugins()
+ /// .add_plugins(DefaultPlugins.build().disable::<LogPlugin>())
+ /// .add_plugins(DefaultBotPlugins);
+ /// # client_builder.set_handler(handle);
+ /// # #[derive(Component, Clone, Default)]
+ /// # pub struct State;
+ /// # async fn handle(mut bot: Client, event: Event, state: State) -> anyhow::Result<()> {
+ /// # Ok(())
+ /// # }
+ /// ```
+ #[must_use]
+ pub fn new_without_plugins() -> Self {
Self {
// we create the app here so plugins can add onto it.
// the schedules won't run until [`Self::start`] is called.
- app: init_ecs_app(),
-
+ app: App::new(),
handler: None,
state: S::default(),
}
- .add_plugins(DefaultBotPlugins)
}
+
/// Set the function that's called every time a bot receives an [`Event`].
/// This is the way to handle normal per-bot events.
///
diff --git a/azalea/src/pathfinder/mod.rs b/azalea/src/pathfinder/mod.rs
index 3f978c95..b7ed222d 100644
--- a/azalea/src/pathfinder/mod.rs
+++ b/azalea/src/pathfinder/mod.rs
@@ -70,6 +70,13 @@ pub trait PathfinderClientExt {
}
impl PathfinderClientExt for azalea_client::Client {
+ /// ```
+ /// # use azalea::prelude::*;
+ /// # use azalea::{BlockPos, pathfinder::BlockPosGoal};
+ /// # fn example(bot: &Client) {
+ /// bot.goto(BlockPosGoal::from(BlockPos::new(0, 70, 0)));
+ /// # }
+ /// ```
fn goto(&self, goal: impl Goal + Send + Sync + 'static) {
self.ecs.lock().send_event(GotoEvent {
entity: self.entity,
diff --git a/azalea/src/pathfinder/moves.rs b/azalea/src/pathfinder/moves.rs
index 6625581d..0dca3c95 100644
--- a/azalea/src/pathfinder/moves.rs
+++ b/azalea/src/pathfinder/moves.rs
@@ -15,7 +15,8 @@ fn is_block_passable(pos: &BlockPos, world: &Instance) -> bool {
/// whether this block has a solid hitbox (i.e. we can stand on it)
fn is_block_solid(pos: &BlockPos, world: &Instance) -> bool {
if let Some(block) = world.chunks.get_block_state(pos) {
- block.shape() == &collision::block_shape()
+ // block.shape() == &collision::block_shape()
+ block.shape() != &collision::empty_shape()
} else {
false
}
diff --git a/azalea/src/swarm/mod.rs b/azalea/src/swarm/mod.rs
index 2253f5bd..0bb9f7cd 100644
--- a/azalea/src/swarm/mod.rs
+++ b/azalea/src/swarm/mod.rs
@@ -5,7 +5,9 @@ mod events;
pub mod prelude;
use crate::{bot::DefaultBotPlugins, HandleFn};
-use azalea_client::{chat::ChatPacket, init_ecs_app, start_ecs, Account, Client, Event, JoinError};
+use azalea_client::{
+ chat::ChatPacket, start_ecs, Account, Client, DefaultPlugins, Event, JoinError,
+};
use azalea_protocol::{
connect::ConnectionError,
resolver::{self, ResolverError},
@@ -83,10 +85,43 @@ where
/// Start creating the swarm.
#[must_use]
pub fn new() -> Self {
+ Self::new_without_plugins()
+ .add_plugins(DefaultPlugins)
+ .add_plugins(DefaultBotPlugins)
+ .add_plugins(DefaultSwarmPlugins)
+ }
+
+ /// [`Self::new`] but without adding the plugins by default. This is useful
+ /// if you want to disable a default plugin.
+ ///
+ /// You **must** add [`DefaultPlugins`], [`DefaultBotPlugins`], and
+ /// [`DefaultSwarmPlugins`] to this.
+ ///
+ /// ```
+ /// # use azalea::{prelude::*, swarm::prelude::*};
+ /// use azalea::{app::PluginGroup, DefaultBotPlugins, DefaultPlugins, swarm::{DefaultSwarmPlugins}};
+ /// use bevy_log::LogPlugin;
+ ///
+ /// let swarm_builder = SwarmBuilder::new_without_plugins()
+ /// .add_plugins(DefaultPlugins.build().disable::<LogPlugin>())
+ /// .add_plugins(DefaultBotPlugins)
+ /// .add_plugins(DefaultSwarmPlugins);
+ /// # swarm_builder.set_handler(handle).set_swarm_handler(swarm_handle);
+ /// # #[derive(Component, Resource, Clone, Default)]
+ /// # pub struct State;
+ /// # async fn handle(mut bot: Client, event: Event, state: State) -> anyhow::Result<()> {
+ /// # Ok(())
+ /// # }
+ /// # async fn swarm_handle(swarm: Swarm, event: SwarmEvent, state: State) -> anyhow::Result<()> {
+ /// # Ok(())
+ /// # }
+ /// ```
+ #[must_use]
+ pub fn new_without_plugins() -> Self {
Self {
// we create the app here so plugins can add onto it.
// the schedules won't run until [`Self::start`] is called.
- app: init_ecs_app(),
+ app: App::new(),
accounts: Vec::new(),
states: Vec::new(),
@@ -95,8 +130,6 @@ where
swarm_handler: None,
join_delay: None,
}
- .add_plugins(DefaultSwarmPlugins)
- .add_plugins(DefaultBotPlugins)
}
/// Add a vec of [`Account`]s to the swarm.