aboutsummaryrefslogtreecommitdiff
path: root/azalea/src
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2023-12-04 23:42:49 -0600
committerGitHub <noreply@github.com>2023-12-04 23:42:49 -0600
commit421d8ce2c837e3140d8f866e63032c277b31a413 (patch)
treed5f06fbcd02c24c6b40edd22cbdfda4d6ed6a39f /azalea/src
parentda4afa8ae3afec4cd59b9a19ae1e04818f1763a7 (diff)
downloadazalea-drasl-421d8ce2c837e3140d8f866e63032c277b31a413.tar.xz
Replace Bevy's FixedUpdate with Azalea's GameTick (#119)
* replace bevy FixedUpdate with azalea GameTick * Update to Bevy 0.12.1
Diffstat (limited to 'azalea/src')
-rw-r--r--azalea/src/bot.rs5
-rw-r--r--azalea/src/pathfinder/mod.rs7
-rw-r--r--azalea/src/pathfinder/simulation.rs11
-rw-r--r--azalea/src/prelude.rs1
-rw-r--r--azalea/src/swarm/mod.rs2
5 files changed, 13 insertions, 13 deletions
diff --git a/azalea/src/bot.rs b/azalea/src/bot.rs
index 2281deaf..ccc016e6 100644
--- a/azalea/src/bot.rs
+++ b/azalea/src/bot.rs
@@ -13,12 +13,13 @@ use azalea_client::interact::SwingArmEvent;
use azalea_client::mining::Mining;
use azalea_client::TickBroadcast;
use azalea_core::position::{BlockPos, Vec3};
+use azalea_core::tick::GameTick;
use azalea_entity::{
clamp_look_direction, metadata::Player, EyeHeight, Jumping, LocalEntity, LookDirection,
Position,
};
use azalea_physics::PhysicsSet;
-use bevy_app::{FixedUpdate, Update};
+use bevy_app::Update;
use bevy_ecs::prelude::Event;
use bevy_ecs::schedule::IntoSystemConfigs;
use futures_lite::Future;
@@ -41,7 +42,7 @@ impl Plugin for BotPlugin {
jump_listener,
),
)
- .add_systems(FixedUpdate, stop_jumping.after(PhysicsSet));
+ .add_systems(GameTick, stop_jumping.after(PhysicsSet));
}
}
diff --git a/azalea/src/pathfinder/mod.rs b/azalea/src/pathfinder/mod.rs
index d9a662f2..789efb07 100644
--- a/azalea/src/pathfinder/mod.rs
+++ b/azalea/src/pathfinder/mod.rs
@@ -28,12 +28,13 @@ use azalea_client::inventory::{InventoryComponent, InventorySet};
use azalea_client::movement::MoveEventsSet;
use azalea_client::{StartSprintEvent, StartWalkEvent};
use azalea_core::position::{BlockPos, Vec3};
+use azalea_core::tick::GameTick;
use azalea_entity::metadata::Player;
use azalea_entity::LocalEntity;
use azalea_entity::{Physics, Position};
use azalea_physics::PhysicsSet;
use azalea_world::{InstanceContainer, InstanceName};
-use bevy_app::{FixedUpdate, PreUpdate, Update};
+use bevy_app::{PreUpdate, Update};
use bevy_ecs::event::Events;
use bevy_ecs::prelude::Event;
use bevy_ecs::query::Changed;
@@ -58,9 +59,9 @@ impl Plugin for PathfinderPlugin {
.add_event::<PathFoundEvent>()
.add_event::<StopPathfindingEvent>()
.add_systems(
- // putting systems in the FixedUpdate schedule makes them run every Minecraft tick
+ // putting systems in the GameTick schedule makes them run every Minecraft tick
// (every 50 milliseconds).
- FixedUpdate,
+ GameTick,
(
timeout_movement,
check_node_reached,
diff --git a/azalea/src/pathfinder/simulation.rs b/azalea/src/pathfinder/simulation.rs
index c6fe096f..88261b7f 100644
--- a/azalea/src/pathfinder/simulation.rs
+++ b/azalea/src/pathfinder/simulation.rs
@@ -1,19 +1,18 @@
//! Simulate the Minecraft world, currently only used for tests.
-use std::{sync::Arc, time::Duration};
+use std::sync::Arc;
use azalea_client::{
inventory::InventoryComponent, packet_handling::game::SendPacketEvent, PhysicsState,
};
-use azalea_core::{position::Vec3, resource_location::ResourceLocation};
+use azalea_core::{position::Vec3, resource_location::ResourceLocation, tick::GameTick};
use azalea_entity::{
attributes::AttributeInstance, metadata::Sprinting, Attributes, EntityDimensions, Physics,
Position,
};
use azalea_world::{ChunkStorage, Instance, InstanceContainer, InstanceName, MinecraftEntityId};
-use bevy_app::{App, FixedUpdate};
+use bevy_app::App;
use bevy_ecs::prelude::*;
-use bevy_time::{Fixed, Time};
use parking_lot::RwLock;
#[derive(Bundle, Clone)]
@@ -71,8 +70,6 @@ impl Simulation {
crate::BotPlugin,
azalea_client::task_pool::TaskPoolPlugin::default(),
))
- // make sure it doesn't do fixed ticks without us telling it to
- .insert_resource(Time::<Fixed>::from_duration(Duration::MAX))
.insert_resource(InstanceContainer {
instances: [(instance_name.clone(), Arc::downgrade(&instance.clone()))]
.iter()
@@ -107,7 +104,7 @@ impl Simulation {
}
}
pub fn tick(&mut self) {
- self.app.world.run_schedule(FixedUpdate);
+ self.app.world.run_schedule(GameTick);
self.app.update();
}
pub fn position(&self) -> Vec3 {
diff --git a/azalea/src/prelude.rs b/azalea/src/prelude.rs
index 87cb0b53..b4d66aaf 100644
--- a/azalea/src/prelude.rs
+++ b/azalea/src/prelude.rs
@@ -9,3 +9,4 @@ pub use azalea_client::{Account, Client, Event};
// this is necessary to make the macros that reference bevy_ecs work
pub use crate::ecs as bevy_ecs;
pub use crate::ecs::{component::Component, system::Resource};
+pub use azalea_core::tick::GameTick;
diff --git a/azalea/src/swarm/mod.rs b/azalea/src/swarm/mod.rs
index 8eb900a1..d485eb30 100644
--- a/azalea/src/swarm/mod.rs
+++ b/azalea/src/swarm/mod.rs
@@ -461,7 +461,7 @@ pub type BoxSwarmHandleFn<SS> =
/// struct SwarmState {}
///
/// #[tokio::main]
-/// async fn main() -> anyhow::Result<()> {
+/// async fn main() {
/// let mut accounts = Vec::new();
/// let mut states = Vec::new();
///