diff --git a/Cargo.lock b/Cargo.lock index 5515af7d..a0afb8c0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -222,6 +222,7 @@ dependencies = [ "priority-queue", "rand", "rustc-hash 2.0.0", + "serde", "thiserror", "tokio", "tracing", diff --git a/azalea/Cargo.toml b/azalea/Cargo.toml index be37c628..55749888 100644 --- a/azalea/Cargo.toml +++ b/azalea/Cargo.toml @@ -8,51 +8,53 @@ version = "0.10.3+mc1.21.1" [package.metadata.release] pre-release-replacements = [ - { file = "README.md", search = "`azalea = \"[a-z0-9\\.-]+\"`", replace = "`azalea = \"{{version}}\"`" }, + { file = "README.md", search = "`azalea = \"[a-z0-9\\.-]+\"`", replace = "`azalea = \"{{version}}\"`" }, ] [dependencies] anyhow = "^1.0.86" async-trait = "0.1.80" +azalea-auth = { version = "0.10.0", path = "../azalea-auth" } azalea-block = { version = "0.10.0", path = "../azalea-block" } +azalea-brigadier = { version = "0.10.0", path = "../azalea-brigadier" } +azalea-buf = { version = "0.10.0", path = "../azalea-buf" } azalea-chat = { version = "0.10.0", path = "../azalea-chat" } azalea-client = { version = "0.10.0", path = "../azalea-client", default-features = false } azalea-core = { version = "0.10.0", path = "../azalea-core" } +azalea-entity = { version = "0.10.0", path = "../azalea-entity" } +azalea-inventory = { version = "0.10.0", path = "../azalea-inventory" } azalea-physics = { version = "0.10.0", path = "../azalea-physics" } azalea-protocol = { version = "0.10.0", path = "../azalea-protocol" } azalea-registry = { version = "0.10.0", path = "../azalea-registry" } azalea-world = { version = "0.10.0", path = "../azalea-world" } -azalea-auth = { version = "0.10.0", path = "../azalea-auth" } -azalea-brigadier = { version = "0.10.0", path = "../azalea-brigadier" } -azalea-buf = { version = "0.10.0", path = "../azalea-buf" } bevy_app = "0.13.0" bevy_ecs = "0.13.0" +bevy_log = "0.13.0" bevy_tasks = { version = "0.13.0", features = ["multi-threaded"] } +bevy_time = "0.13.0" derive_more = { version = "0.99.18", features = ["deref", "deref_mut"] } futures = "0.3.30" futures-lite = "2.3.0" -tracing = "0.1.40" nohash-hasher = "0.2.0" num-traits = "0.2.19" parking_lot = { version = "^0.12.3", features = ["deadlock_detection"] } priority-queue = "2.0.3" +rustc-hash = "2.0.0" +serde = { version = "1", optional = true } thiserror = "^1.0.61" tokio = "^1.38.0" +tracing = "0.1.40" uuid = "1.9.1" -bevy_log = "0.13.0" -bevy_time = "0.13.0" -rustc-hash = "2.0.0" -azalea-inventory = { version = "0.10.0", path = "../azalea-inventory" } -azalea-entity = { version = "0.10.0", path = "../azalea-entity" } [dev-dependencies] criterion = "0.5.1" rand = "0.8.5" [features] -default = ["log"] +default = ["log", "serde"] # enables bevy_log::LogPlugin by default log = ["azalea-client/log"] +serde = ["dep:serde"] [[bench]] name = "pathfinder" diff --git a/azalea/src/pathfinder/goals.rs b/azalea/src/pathfinder/goals.rs index 3f8c7993..7e02d0cf 100644 --- a/azalea/src/pathfinder/goals.rs +++ b/azalea/src/pathfinder/goals.rs @@ -1,9 +1,10 @@ //! The goals that a pathfinder can try to reach. -use std::f32::consts::SQRT_2; - use azalea_core::position::{BlockPos, Vec3}; use azalea_world::ChunkStorage; +#[cfg(feature = "serde")] +use serde::{Deserialize, Serialize}; +use std::f32::consts::SQRT_2; use super::costs::{COST_HEURISTIC, FALL_N_BLOCKS_COST, JUMP_ONE_BLOCK_COST}; @@ -15,7 +16,8 @@ pub trait Goal { } /// Move to the given block position. -#[derive(Debug)] +#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] pub struct BlockPosGoal(pub BlockPos); impl Goal for BlockPosGoal { fn heuristic(&self, n: BlockPos) -> f32 { @@ -48,8 +50,9 @@ fn xz_heuristic(dx: f32, dz: f32) -> f32 { (diagonal * SQRT_2 + straight) * COST_HEURISTIC } -/// Move to the given block position, ignoring the y axis. -#[derive(Debug)] +/// Move to the given block position, ignoring the y-axis. +#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] pub struct XZGoal { pub x: i32, pub z: i32, @@ -74,7 +77,8 @@ fn y_heuristic(dy: f32) -> f32 { } /// Move to the given y coordinate. -#[derive(Debug)] +#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] pub struct YGoal { pub y: i32, } @@ -89,7 +93,8 @@ impl Goal for YGoal { } /// Get within the given radius of the given position. -#[derive(Debug)] +#[derive(Clone, Copy, Debug, Default, PartialEq)] +#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] pub struct RadiusGoal { pub pos: Vec3, pub radius: f32, @@ -163,7 +168,7 @@ impl Goal for AndGoal { } } -/// Try to reach all of the given goals. +/// Try to reach all the given goals. #[derive(Debug)] pub struct AndGoals(pub Vec); impl Goal for AndGoals { @@ -180,7 +185,7 @@ impl Goal for AndGoals { } /// Move to a position where we can reach the given block. -#[derive(Debug)] +#[derive(Clone, Debug)] pub struct ReachBlockPosGoal { pub pos: BlockPos, pub chunk_storage: ChunkStorage,