aboutsummaryrefslogtreecommitdiff
path: root/azalea/src
diff options
context:
space:
mode:
authorEightFactorial <29801334+EightFactorial@users.noreply.github.com>2024-12-04 16:31:22 -0800
committerGitHub <noreply@github.com>2024-12-04 18:31:22 -0600
commit6379035b852f1b619565d27f5cee3b93042c2312 (patch)
tree30c858cfaf841d0fcc5a139f1507b9b67d768e8b /azalea/src
parent241c7527ce11177082dcc0ebc4152506946ee684 (diff)
downloadazalea-drasl-6379035b852f1b619565d27f5cee3b93042c2312.tar.xz
Update Bevy and migrate to workspace dependencies and package attributes (#181)
* Use workspace `Cargo.toml` for dependencies and package atributes * Fix a couple clippy warnings * Update bevy, update build script, move deps to workspace, and fix clippy warnings * Remove carrots from crate versions The default behavior is the same * Remove unused dependencies Compiles and all tests pass, so it should be fine * Update codegen to use `std::sync::LazyLock` instead of `once_cell::sync::Lazy` * Update Bevy to `0.15.0-rc.3` Surprisingly little needed to be changed * Update to bevy 0.15.0 * Fix leftover merge issues * Clarify the reason the swarm can't connect * Fix duplicate lint, remove `log` dependency
Diffstat (limited to 'azalea/src')
-rw-r--r--azalea/src/pathfinder/mod.rs2
-rw-r--r--azalea/src/pathfinder/simulation.rs16
-rw-r--r--azalea/src/swarm/chat.rs36
-rw-r--r--azalea/src/swarm/mod.rs14
4 files changed, 39 insertions, 29 deletions
diff --git a/azalea/src/pathfinder/mod.rs b/azalea/src/pathfinder/mod.rs
index 88ae5da0..eab07348 100644
--- a/azalea/src/pathfinder/mod.rs
+++ b/azalea/src/pathfinder/mod.rs
@@ -875,7 +875,7 @@ mod tests {
// filter: "".to_string(),
// });
- simulation.app.world.send_event(GotoEvent {
+ simulation.app.world_mut().send_event(GotoEvent {
entity: simulation.entity,
goal: Arc::new(BlockPosGoal(end_pos)),
successors_fn: moves::default_move,
diff --git a/azalea/src/pathfinder/simulation.rs b/azalea/src/pathfinder/simulation.rs
index ae76896c..ca15fb7a 100644
--- a/azalea/src/pathfinder/simulation.rs
+++ b/azalea/src/pathfinder/simulation.rs
@@ -130,7 +130,7 @@ pub struct Simulation {
impl Simulation {
pub fn new(chunks: ChunkStorage, player: SimulatedPlayerBundle) -> Self {
let (mut app, instance) = create_simulation_instance(chunks);
- let entity = create_simulation_player(&mut app.world, instance.clone(), player);
+ let entity = create_simulation_player(app.world_mut(), instance.clone(), player);
Self {
app,
entity,
@@ -140,13 +140,13 @@ impl Simulation {
pub fn tick(&mut self) {
self.app.update();
- self.app.world.run_schedule(GameTick);
+ self.app.world_mut().run_schedule(GameTick);
}
pub fn component<T: Component + Clone>(&self) -> T {
- self.app.world.get::<T>(self.entity).unwrap().clone()
+ self.app.world().get::<T>(self.entity).unwrap().clone()
}
pub fn get_component<T: Component + Clone>(&self) -> Option<T> {
- self.app.world.get::<T>(self.entity).cloned()
+ self.app.world().get::<T>(self.entity).cloned()
}
pub fn position(&self) -> Vec3 {
*self.component::<Position>()
@@ -171,17 +171,17 @@ impl SimulationSet {
}
pub fn tick(&mut self) {
self.app.update();
- self.app.world.run_schedule(GameTick);
+ self.app.world_mut().run_schedule(GameTick);
}
pub fn spawn(&mut self, player: SimulatedPlayerBundle) -> Entity {
- create_simulation_player(&mut self.app.world, self.instance.clone(), player)
+ create_simulation_player(self.app.world_mut(), self.instance.clone(), player)
}
pub fn despawn(&mut self, entity: Entity) {
- self.app.world.despawn(entity);
+ self.app.world_mut().despawn(entity);
}
pub fn position(&self, entity: Entity) -> Vec3 {
- **self.app.world.get::<Position>(entity).unwrap()
+ **self.app.world().get::<Position>(entity).unwrap()
}
}
diff --git a/azalea/src/swarm/chat.rs b/azalea/src/swarm/chat.rs
index cf01c60b..f56c1511 100644
--- a/azalea/src/swarm/chat.rs
+++ b/azalea/src/swarm/chat.rs
@@ -188,70 +188,70 @@ mod tests {
async fn test_swarm_chat() {
let mut app = make_test_app();
- let bot0 = app.world.spawn_empty().id();
- let bot1 = app.world.spawn_empty().id();
+ let bot0 = app.world_mut().spawn_empty().id();
+ let bot1 = app.world_mut().spawn_empty().id();
- app.world.send_event(ChatReceivedEvent {
+ app.world_mut().send_event(ChatReceivedEvent {
entity: bot0,
packet: ChatPacket::new("a"),
});
app.update();
// the swarm should get the event immediately after the bot gets it
- assert_eq!(drain_events(&mut app.world), vec![ChatPacket::new("a")]);
+ assert_eq!(drain_events(app.world_mut()), vec![ChatPacket::new("a")]);
assert_eq!(
- app.world.get::<ClientChatState>(bot0).unwrap().chat_index,
+ app.world().get::<ClientChatState>(bot0).unwrap().chat_index,
1
);
// and a second bot sending the event shouldn't do anything
- app.world.send_event(ChatReceivedEvent {
+ app.world_mut().send_event(ChatReceivedEvent {
entity: bot1,
packet: ChatPacket::new("a"),
});
app.update();
- assert_eq!(drain_events(&mut app.world), vec![]);
+ assert_eq!(drain_events(app.world_mut()), vec![]);
assert_eq!(
- app.world.get::<ClientChatState>(bot1).unwrap().chat_index,
+ app.world().get::<ClientChatState>(bot1).unwrap().chat_index,
1
);
// but if the first one gets it again, it should sent it again
- app.world.send_event(ChatReceivedEvent {
+ app.world_mut().send_event(ChatReceivedEvent {
entity: bot0,
packet: ChatPacket::new("a"),
});
app.update();
- assert_eq!(drain_events(&mut app.world), vec![ChatPacket::new("a")]);
+ assert_eq!(drain_events(app.world_mut()), vec![ChatPacket::new("a")]);
// alright and now the second bot got a different chat message and it should be
// sent
- app.world.send_event(ChatReceivedEvent {
+ app.world_mut().send_event(ChatReceivedEvent {
entity: bot1,
packet: ChatPacket::new("b"),
});
app.update();
- assert_eq!(drain_events(&mut app.world), vec![ChatPacket::new("b")]);
+ assert_eq!(drain_events(app.world_mut()), vec![ChatPacket::new("b")]);
}
#[tokio::test]
async fn test_new_bot() {
let mut app = make_test_app();
- let bot0 = app.world.spawn_empty().id();
+ let bot0 = app.world_mut().spawn_empty().id();
// bot0 gets a chat message
- app.world.send_event(ChatReceivedEvent {
+ app.world_mut().send_event(ChatReceivedEvent {
entity: bot0,
packet: ChatPacket::new("a"),
});
app.update();
- assert_eq!(drain_events(&mut app.world), vec![ChatPacket::new("a")]);
- let bot1 = app.world.spawn_empty().id();
- app.world.send_event(ChatReceivedEvent {
+ assert_eq!(drain_events(app.world_mut()), vec![ChatPacket::new("a")]);
+ let bot1 = app.world_mut().spawn_empty().id();
+ app.world_mut().send_event(ChatReceivedEvent {
entity: bot1,
packet: ChatPacket::new("b"),
});
app.update();
- assert_eq!(drain_events(&mut app.world), vec![ChatPacket::new("b")]);
+ assert_eq!(drain_events(app.world_mut()), vec![ChatPacket::new("b")]);
}
}
diff --git a/azalea/src/swarm/mod.rs b/azalea/src/swarm/mod.rs
index 31f018cf..24b336fd 100644
--- a/azalea/src/swarm/mod.rs
+++ b/azalea/src/swarm/mod.rs
@@ -368,7 +368,7 @@ where
let (run_schedule_sender, run_schedule_receiver) = mpsc::unbounded_channel();
- let main_schedule_label = self.app.main_schedule_label;
+ let main_schedule_label = self.app.main().update_schedule.unwrap();
let ecs_lock =
start_ecs_runner(self.app, run_schedule_receiver, run_schedule_sender.clone());
@@ -671,7 +671,17 @@ impl Swarm {
let delay = (Duration::from_secs(5) * 2u32.pow(disconnects.min(16)))
.min(Duration::from_secs(15));
let username = account.username.clone();
- error!("Error joining as {username}: {e}. Waiting {delay:?} and trying again.");
+
+ if let JoinError::Disconnect { reason } = &e {
+ error!(
+ "Error joining as {username}, server says: \"{reason}\". Waiting {delay:?} and trying again."
+ );
+ } else {
+ error!(
+ "Error joining as {username}: {e}. Waiting {delay:?} and trying again."
+ );
+ }
+
tokio::time::sleep(delay).await;
}
}