aboutsummaryrefslogtreecommitdiff
path: root/azalea/src/pathfinder
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2025-04-25 01:10:03 -0100
committermat <git@matdoes.dev>2025-04-25 01:10:03 -0100
commitb3af8d73faa2663e25e5688897720e57842f99ae (patch)
treefdc16e01fabce7b7ec4e9f1ff702fe3e6c10dfe5 /azalea/src/pathfinder
parent65c9f555b0274ce9c56aafb73f3f59dbf80f3a85 (diff)
downloadazalea-drasl-b3af8d73faa2663e25e5688897720e57842f99ae.tar.xz
update to bevy 0.16
Diffstat (limited to 'azalea/src/pathfinder')
-rw-r--r--azalea/src/pathfinder/mod.rs24
-rw-r--r--azalea/src/pathfinder/moves/mod.rs14
2 files changed, 18 insertions, 20 deletions
diff --git a/azalea/src/pathfinder/mod.rs b/azalea/src/pathfinder/mod.rs
index c747ef67..aba8610a 100644
--- a/azalea/src/pathfinder/mod.rs
+++ b/azalea/src/pathfinder/mod.rs
@@ -32,9 +32,7 @@ use azalea_entity::{Physics, Position};
use azalea_physics::PhysicsSet;
use azalea_world::{InstanceContainer, InstanceName};
use bevy_app::{PreUpdate, Update};
-use bevy_ecs::prelude::Event;
-use bevy_ecs::query::Changed;
-use bevy_ecs::schedule::IntoSystemConfigs;
+use bevy_ecs::prelude::*;
use bevy_tasks::{AsyncComputeTaskPool, Task};
use futures_lite::future;
use goals::BlockPosGoal;
@@ -477,7 +475,7 @@ pub fn handle_tasks(
for (entity, mut task) in &mut transform_tasks {
if let Some(optional_path_found_event) = future::block_on(future::poll_once(&mut task.0)) {
if let Some(path_found_event) = optional_path_found_event {
- path_found_events.send(path_found_event);
+ path_found_events.write(path_found_event);
}
// Task is complete, so remove task component from entity
@@ -698,7 +696,7 @@ pub fn check_node_reached(
if executing_path.path.is_empty() {
info!("the path we just swapped to was empty, so reached end of path");
- walk_events.send(StartWalkEvent {
+ walk_events.write(StartWalkEvent {
entity,
direction: WalkDirection::None,
});
@@ -712,7 +710,7 @@ pub fn check_node_reached(
if executing_path.path.is_empty() {
debug!("pathfinder path is now empty");
- walk_events.send(StartWalkEvent {
+ walk_events.write(StartWalkEvent {
entity,
direction: WalkDirection::None,
});
@@ -923,7 +921,7 @@ pub fn recalculate_near_end_of_path(
"recalculate_near_end_of_path executing_path.is_path_partial: {}",
executing_path.is_path_partial
);
- goto_events.send(GotoEvent {
+ goto_events.write(GotoEvent {
entity,
goal,
successors_fn,
@@ -947,7 +945,7 @@ pub fn recalculate_near_end_of_path(
info!(
"the path we just swapped to was empty, so reached end of path"
);
- walk_events.send(StartWalkEvent {
+ walk_events.write(StartWalkEvent {
entity,
direction: WalkDirection::None,
});
@@ -955,7 +953,7 @@ pub fn recalculate_near_end_of_path(
break;
}
} else {
- walk_events.send(StartWalkEvent {
+ walk_events.write(StartWalkEvent {
entity,
direction: WalkDirection::None,
});
@@ -966,7 +964,7 @@ pub fn recalculate_near_end_of_path(
_ => {
if executing_path.path.is_empty() {
// idk when this can happen but stop moving just in case
- walk_events.send(StartWalkEvent {
+ walk_events.write(StartWalkEvent {
entity,
direction: WalkDirection::None,
});
@@ -1033,7 +1031,7 @@ pub fn recalculate_if_has_goal_but_no_path(
if pathfinder.goal.is_some() && !pathfinder.is_calculating {
if let Some(goal) = pathfinder.goal.as_ref().cloned() {
debug!("Recalculating path because it has a goal but no ExecutingPath");
- goto_events.send(GotoEvent {
+ goto_events.write(GotoEvent {
entity,
goal,
successors_fn: pathfinder.successors_fn.unwrap(),
@@ -1081,7 +1079,7 @@ pub fn handle_stop_pathfinding_event(
}
if executing_path.path.is_empty() {
- walk_events.send(StartWalkEvent {
+ walk_events.write(StartWalkEvent {
entity: event.entity,
direction: WalkDirection::None,
});
@@ -1098,7 +1096,7 @@ pub fn stop_pathfinding_on_instance_change(
if !executing_path.path.is_empty() {
debug!("instance changed, clearing path");
executing_path.path.clear();
- stop_pathfinding_events.send(StopPathfindingEvent {
+ stop_pathfinding_events.write(StopPathfindingEvent {
entity,
force: true,
});
diff --git a/azalea/src/pathfinder/moves/mod.rs b/azalea/src/pathfinder/moves/mod.rs
index 83e6369f..150dad52 100644
--- a/azalea/src/pathfinder/moves/mod.rs
+++ b/azalea/src/pathfinder/moves/mod.rs
@@ -68,7 +68,7 @@ pub struct ExecuteCtx<'w1, 'w2, 'w3, 'w4, 'w5, 'w6, 'a> {
impl ExecuteCtx<'_, '_, '_, '_, '_, '_, '_> {
pub fn look_at(&mut self, position: Vec3) {
- self.look_at_events.send(LookAtEvent {
+ self.look_at_events.write(LookAtEvent {
entity: self.entity,
position: Vec3 {
x: position.x,
@@ -80,28 +80,28 @@ impl ExecuteCtx<'_, '_, '_, '_, '_, '_, '_> {
}
pub fn look_at_exact(&mut self, position: Vec3) {
- self.look_at_events.send(LookAtEvent {
+ self.look_at_events.write(LookAtEvent {
entity: self.entity,
position,
});
}
pub fn sprint(&mut self, direction: SprintDirection) {
- self.sprint_events.send(StartSprintEvent {
+ self.sprint_events.write(StartSprintEvent {
entity: self.entity,
direction,
});
}
pub fn walk(&mut self, direction: WalkDirection) {
- self.walk_events.send(StartWalkEvent {
+ self.walk_events.write(StartWalkEvent {
entity: self.entity,
direction,
});
}
pub fn jump(&mut self) {
- self.jump_events.send(JumpEvent {
+ self.jump_events.write(JumpEvent {
entity: self.entity,
});
}
@@ -137,7 +137,7 @@ impl ExecuteCtx<'_, '_, '_, '_, '_, '_, '_> {
let best_tool_result = best_tool_in_hotbar_for_block(block_state, &self.menu);
self.set_selected_hotbar_slot_events
- .send(SetSelectedHotbarSlotEvent {
+ .write(SetSelectedHotbarSlotEvent {
entity: self.entity,
slot: best_tool_result.index as u8,
});
@@ -146,7 +146,7 @@ impl ExecuteCtx<'_, '_, '_, '_, '_, '_, '_> {
self.walk(WalkDirection::None);
self.look_at_exact(block.center());
- self.start_mining_events.send(StartMiningBlockEvent {
+ self.start_mining_events.write(StartMiningBlockEvent {
entity: self.entity,
position: block,
});