From 7fc31f9506df8a0ad532741576473aedd13786b1 Mon Sep 17 00:00:00 2001 From: veronoicc <64193056+veronoicc@users.noreply.github.com> Date: Fri, 8 Mar 2024 17:56:55 +0100 Subject: [PATCH 1/5] Update clientbound_game_event_packet.rs (#133) Added 2 new game even types --- .../src/packets/game/clientbound_game_event_packet.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/azalea-protocol/src/packets/game/clientbound_game_event_packet.rs b/azalea-protocol/src/packets/game/clientbound_game_event_packet.rs index bd1b2ab61..2416f7c33 100755 --- a/azalea-protocol/src/packets/game/clientbound_game_event_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_game_event_packet.rs @@ -21,4 +21,6 @@ pub enum EventType { PufferFishSting = 9, GuardianElderEffect = 10, ImmediateRespawn = 11, + LimitedCrafting = 12, + WaitForLevelChunks = 13, } From 38bb98707e92747910793669d2f03dc7ee9533fd Mon Sep 17 00:00:00 2001 From: 1zuna Date: Thu, 21 Mar 2024 19:36:15 +0100 Subject: [PATCH 2/5] fix: GameOwnershipResponse key_id format (#138) --- azalea-auth/src/auth.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/azalea-auth/src/auth.rs b/azalea-auth/src/auth.rs index 7b5846c42..e0a75adff 100755 --- a/azalea-auth/src/auth.rs +++ b/azalea-auth/src/auth.rs @@ -238,6 +238,7 @@ pub struct MinecraftAuthResponse { pub struct GameOwnershipResponse { pub items: Vec, pub signature: String, + #[serde(rename = "keyId")] pub key_id: String, } From cadc5605ec143d391382a77a431b55b44f5c5153 Mon Sep 17 00:00:00 2001 From: mat Date: Mon, 26 Feb 2024 17:13:05 -0600 Subject: [PATCH 3/5] make recalculate_near_end_of_path public so other plugins can do .after(recalculate_near_end_of_path) --- azalea/src/pathfinder/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azalea/src/pathfinder/mod.rs b/azalea/src/pathfinder/mod.rs index 360c4df51..a1bdaaad3 100644 --- a/azalea/src/pathfinder/mod.rs +++ b/azalea/src/pathfinder/mod.rs @@ -618,7 +618,7 @@ fn check_for_path_obstruction( } } -fn recalculate_near_end_of_path( +pub fn recalculate_near_end_of_path( mut query: Query<(Entity, &mut Pathfinder, &mut ExecutingPath)>, mut walk_events: EventWriter, mut goto_events: EventWriter, From b66b5b6b9042c3817ebb6d426c5ecd523b271c32 Mon Sep 17 00:00:00 2001 From: mat Date: Tue, 9 Apr 2024 07:15:30 +0000 Subject: [PATCH 4/5] add functions to ClientBuilder and SwarmBuilder for custom addresses --- azalea/src/lib.rs | 21 +++++++++++++++++++++ azalea/src/swarm/mod.rs | 42 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 60 insertions(+), 3 deletions(-) diff --git a/azalea/src/lib.rs b/azalea/src/lib.rs index 84c215d54..6e18ff7d4 100644 --- a/azalea/src/lib.rs +++ b/azalea/src/lib.rs @@ -15,6 +15,8 @@ pub mod pathfinder; pub mod prelude; pub mod swarm; +use std::net::SocketAddr; + use app::Plugins; pub use azalea_auth as auth; pub use azalea_block as blocks; @@ -189,6 +191,25 @@ where } self.swarm.start(address).await } + + /// Do the same as [`Self::start`], but allow passing in a custom resolved + /// address. This is useful if the address you're connecting to doesn't + /// resolve to anything, like if the server uses the address field to pass + /// custom data (like Bungeecord or Forge). + pub async fn start_with_custom_resolved_address( + mut self, + account: Account, + address: impl TryInto, + resolved_address: SocketAddr, + ) -> Result { + self.swarm.accounts = vec![account]; + if self.swarm.states.is_empty() { + self.swarm.states = vec![S::default()]; + } + self.swarm + .start_with_custom_resolved_address(address, resolved_address) + .await + } } impl Default for ClientBuilder { fn default() -> Self { diff --git a/azalea/src/swarm/mod.rs b/azalea/src/swarm/mod.rs index 6d3885ef1..2be56567e 100644 --- a/azalea/src/swarm/mod.rs +++ b/azalea/src/swarm/mod.rs @@ -296,6 +296,28 @@ where /// /// [`ServerAddress`]: azalea_protocol::ServerAddress pub async fn start(self, address: impl TryInto) -> Result { + // convert the TryInto into a ServerAddress + let address: ServerAddress = match address.try_into() { + Ok(address) => address, + Err(_) => return Err(StartError::InvalidAddress), + }; + + // resolve the address + let resolved_address = resolver::resolve_address(&address).await?; + + self.start_with_custom_resolved_address(address, resolved_address) + .await + } + + /// Do the same as [`Self::start`], but allow passing in a custom resolved + /// address. This is useful if the address you're connecting to doesn't + /// resolve to anything, like if the server uses the address field to pass + /// custom data (like Bungeecord or Forge). + pub async fn start_with_custom_resolved_address( + self, + address: impl TryInto, + resolved_address: SocketAddr, + ) -> Result { assert_eq!( self.accounts.len(), self.states.len(), @@ -308,9 +330,6 @@ where Err(_) => return Err(StartError::InvalidAddress), }; - // resolve the address - let resolved_address = resolver::resolve_address(&address).await?; - let instance_container = Arc::new(RwLock::new(InstanceContainer::default())); // we can't modify the swarm plugins after this @@ -528,6 +547,23 @@ impl Swarm { let address = self.address.read().clone(); let resolved_address = *self.resolved_address.read(); + self.add_with_custom_address(account, state, address, resolved_address) + .await + } + /// Add a new account to the swarm, using the given host and socket + /// address. This is useful if you want bots in the same swarm to connect to + /// different addresses. Usually you'll just want [`Self::add`] though. + /// + /// # Errors + /// + /// Returns an `Err` if the bot could not do a handshake successfully. + pub async fn add_with_custom_address( + &mut self, + account: &Account, + state: S, + address: ServerAddress, + resolved_address: SocketAddr, + ) -> Result { let (bot, mut rx) = Client::start_client( self.ecs_lock.clone(), account, From 8808ecef9416edca9c77296742a533e848fba075 Mon Sep 17 00:00:00 2001 From: mat Date: Thu, 18 Apr 2024 19:52:13 -0500 Subject: [PATCH 5/5] fix get_block_collisions panicking when starting in a non existent chunk --- azalea-physics/src/collision/world_collisions.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/azalea-physics/src/collision/world_collisions.rs b/azalea-physics/src/collision/world_collisions.rs index 54493d622..4a3c2c3b3 100644 --- a/azalea-physics/src/collision/world_collisions.rs +++ b/azalea-physics/src/collision/world_collisions.rs @@ -15,8 +15,8 @@ pub fn get_block_collisions(world: &Instance, aabb: AABB) -> Vec { let mut block_collisions = Vec::new(); let initial_chunk_pos = ChunkPos::from(state.cursor.origin()); - let initial_chunk = world.chunks.get(&initial_chunk_pos).unwrap(); - let initial_chunk = initial_chunk.read(); + let initial_chunk = world.chunks.get(&initial_chunk_pos); + let initial_chunk = initial_chunk.as_deref().map(RwLock::read); while let Some(item) = state.cursor.next() { if item.iteration_type == CursorIterationType::Corner { @@ -25,9 +25,13 @@ pub fn get_block_collisions(world: &Instance, aabb: AABB) -> Vec { let item_chunk_pos = ChunkPos::from(item.pos); let block_state: BlockState = if item_chunk_pos == initial_chunk_pos { - initial_chunk - .get(&ChunkBlockPos::from(item.pos), state.world.chunks.min_y) - .unwrap_or(BlockState::AIR) + if let Some(initial_chunk) = &initial_chunk { + initial_chunk + .get(&ChunkBlockPos::from(item.pos), state.world.chunks.min_y) + .unwrap_or(BlockState::AIR) + } else { + BlockState::AIR + } } else { state.get_block_state(item.pos) };