aboutsummaryrefslogtreecommitdiff
path: root/azalea-physics/src
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2023-09-11 22:58:54 -0500
committermat <git@matdoes.dev>2023-09-11 22:59:05 -0500
commitf8cca413613918a59520ac62c188e194fa27b300 (patch)
treecf15ef4426a3896c20ceeec530d66e7aa599ae5d /azalea-physics/src
parentbcefa64dd192918cfeb1bba27cb4993bec6a17e3 (diff)
downloadazalea-drasl-f8cca413613918a59520ac62c188e194fa27b300.tar.xz
fix falling through blocks on spawn (and triggering anticheats)
Diffstat (limited to 'azalea-physics/src')
-rw-r--r--azalea-physics/src/collision/world_collisions.rs4
-rw-r--r--azalea-physics/src/lib.rs19
2 files changed, 14 insertions, 9 deletions
diff --git a/azalea-physics/src/collision/world_collisions.rs b/azalea-physics/src/collision/world_collisions.rs
index e640f0ce..414b4c58 100644
--- a/azalea-physics/src/collision/world_collisions.rs
+++ b/azalea-physics/src/collision/world_collisions.rs
@@ -71,7 +71,9 @@ impl<'a> Iterator for BlockCollisions<'a> {
}
let chunk = self.get_chunk(item.pos.x, item.pos.z);
- let Some(chunk) = chunk else { continue };
+ let Some(chunk) = chunk else {
+ continue;
+ };
let pos = item.pos;
let block_state: BlockState = chunk
diff --git a/azalea-physics/src/lib.rs b/azalea-physics/src/lib.rs
index 06138cf7..143f99ab 100644
--- a/azalea-physics/src/lib.rs
+++ b/azalea-physics/src/lib.rs
@@ -7,8 +7,8 @@ pub mod collision;
use azalea_block::{Block, BlockState};
use azalea_core::{math, BlockPos, Vec3};
use azalea_entity::{
- metadata::Sprinting, move_relative, Attributes, Jumping, Local, LookDirection, Physics,
- Position,
+ metadata::Sprinting, move_relative, Attributes, InLoadedChunk, Jumping, Local, LookDirection,
+ Physics, Position,
};
use azalea_world::{Instance, InstanceContainer, InstanceName};
use bevy_app::{App, FixedUpdate, Plugin};
@@ -26,7 +26,13 @@ pub struct PhysicsSet;
pub struct PhysicsPlugin;
impl Plugin for PhysicsPlugin {
fn build(&self, app: &mut App) {
- app.add_systems(FixedUpdate, (ai_step, travel).chain().in_set(PhysicsSet));
+ app.add_systems(
+ FixedUpdate,
+ (ai_step, travel)
+ .chain()
+ .in_set(PhysicsSet)
+ .after(azalea_entity::update_in_loaded_chunk),
+ );
}
}
@@ -43,7 +49,7 @@ fn travel(
&Attributes,
&InstanceName,
),
- With<Local>,
+ (With<Local>, With<InLoadedChunk>),
>,
instance_container: Res<InstanceContainer>,
) {
@@ -126,10 +132,7 @@ pub fn ai_step(
&Sprinting,
&InstanceName,
),
- With<Local>,
- // TODO: ai_step should only run for players in loaded chunks
- // With<LocalPlayerInLoadedChunk> maybe there should be an InLoadedChunk/InUnloadedChunk
- // component?
+ (With<Local>, With<InLoadedChunk>),
>,
instance_container: Res<InstanceContainer>,
) {