diff options
| author | mat <git@matdoes.dev> | 2025-08-12 20:50:40 -1030 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2025-08-12 20:50:40 -1030 |
| commit | 55a7db13ef028f5b6c6e87a81406b3525cea196f (patch) | |
| tree | 6a995bc0b46c527e9fab0874508f81e07deb673e /azalea-physics | |
| parent | ac66744586880afd657969ae078700a9749e293a (diff) | |
| download | azalea-drasl-55a7db13ef028f5b6c6e87a81406b3525cea196f.tar.xz | |
send correct packets on teleport
Diffstat (limited to 'azalea-physics')
| -rw-r--r-- | azalea-physics/src/collision/mod.rs | 6 | ||||
| -rw-r--r-- | azalea-physics/src/fluids.rs | 10 | ||||
| -rw-r--r-- | azalea-physics/src/lib.rs | 6 | ||||
| -rw-r--r-- | azalea-physics/src/travel.rs | 4 | ||||
| -rw-r--r-- | azalea-physics/tests/physics.rs | 10 |
5 files changed, 22 insertions, 14 deletions
diff --git a/azalea-physics/src/collision/mod.rs b/azalea-physics/src/collision/mod.rs index 41fc6c85..dc439f7b 100644 --- a/azalea-physics/src/collision/mod.rs +++ b/azalea-physics/src/collision/mod.rs @@ -171,11 +171,11 @@ pub fn move_colliding( let x_collision = movement.x != collide_result.x; let z_collision = movement.z != collide_result.z; let horizontal_collision = x_collision || z_collision; - let vertical_collision = movement.y != collide_result.y; - let on_ground = vertical_collision && movement.y < 0.; - physics.horizontal_collision = horizontal_collision; + + let vertical_collision = movement.y != collide_result.y; physics.vertical_collision = vertical_collision; + let on_ground = vertical_collision && movement.y < 0.; physics.set_on_ground(on_ground); // TODO: minecraft checks for a "minor" horizontal collision here diff --git a/azalea-physics/src/fluids.rs b/azalea-physics/src/fluids.rs index ea0f12e2..c37a9917 100644 --- a/azalea-physics/src/fluids.rs +++ b/azalea-physics/src/fluids.rs @@ -7,7 +7,7 @@ use azalea_core::{ position::{BlockPos, Vec3}, resource_location::ResourceLocation, }; -use azalea_entity::{InLoadedChunk, LocalEntity, Physics, Position}; +use azalea_entity::{HasClientLoaded, LocalEntity, Physics, Position}; use azalea_world::{Instance, InstanceContainer, InstanceName}; use bevy_ecs::prelude::*; @@ -17,14 +17,14 @@ use crate::collision::legacy_blocks_motion; pub fn update_in_water_state_and_do_fluid_pushing( mut query: Query< (&mut Physics, &Position, &InstanceName), - (With<LocalEntity>, With<InLoadedChunk>), + (With<LocalEntity>, With<HasClientLoaded>), >, instance_container: Res<InstanceContainer>, ) { for (mut physics, position, instance_name) in &mut query { - let world_lock = instance_container - .get(instance_name) - .expect("All entities with InLoadedChunk should be in a valid world"); + let Some(world_lock) = instance_container.get(instance_name) else { + continue; + }; let world = world_lock.read(); // reset the heights since they're going to be set in diff --git a/azalea-physics/src/lib.rs b/azalea-physics/src/lib.rs index 2063f0f0..27250f61 100644 --- a/azalea-physics/src/lib.rs +++ b/azalea-physics/src/lib.rs @@ -15,7 +15,7 @@ use azalea_core::{ tick::GameTick, }; use azalea_entity::{ - Attributes, EntityKindComponent, InLoadedChunk, Jumping, LocalEntity, LookDirection, + Attributes, EntityKindComponent, HasClientLoaded, Jumping, LocalEntity, LookDirection, OnClimbable, Physics, Pose, Position, metadata::Sprinting, move_relative, }; use azalea_registry::{Block, EntityKind}; @@ -68,7 +68,7 @@ pub fn ai_step( &InstanceName, &EntityKindComponent, ), - (With<LocalEntity>, With<InLoadedChunk>), + (With<LocalEntity>, With<HasClientLoaded>), >, instance_container: Res<InstanceContainer>, ) { @@ -162,7 +162,7 @@ fn jump_in_liquid(physics: &mut Physics) { pub fn apply_effects_from_blocks( mut query: Query< (&mut Physics, &Position, &InstanceName), - (With<LocalEntity>, With<InLoadedChunk>), + (With<LocalEntity>, With<HasClientLoaded>), >, instance_container: Res<InstanceContainer>, ) { diff --git a/azalea-physics/src/travel.rs b/azalea-physics/src/travel.rs index 9af3ed27..80c289d9 100644 --- a/azalea-physics/src/travel.rs +++ b/azalea-physics/src/travel.rs @@ -4,7 +4,7 @@ use azalea_core::{ position::{BlockPos, Vec3}, }; use azalea_entity::{ - Attributes, InLoadedChunk, Jumping, LocalEntity, LookDirection, OnClimbable, Physics, Pose, + Attributes, HasClientLoaded, Jumping, LocalEntity, LookDirection, OnClimbable, Physics, Pose, Position, metadata::Sprinting, move_relative, }; use azalea_world::{Instance, InstanceContainer, InstanceName}; @@ -37,7 +37,7 @@ pub fn travel( &OnClimbable, &Jumping, ), - (With<LocalEntity>, With<InLoadedChunk>), + (With<LocalEntity>, With<HasClientLoaded>), >, instance_container: Res<InstanceContainer>, physics_query: PhysicsQuery, diff --git a/azalea-physics/tests/physics.rs b/azalea-physics/tests/physics.rs index 8150e5b0..b312b31e 100644 --- a/azalea-physics/tests/physics.rs +++ b/azalea-physics/tests/physics.rs @@ -10,7 +10,7 @@ use azalea_core::{ resource_location::ResourceLocation, tick::GameTick, }; -use azalea_entity::{EntityBundle, EntityPlugin, LocalEntity, Physics, Position}; +use azalea_entity::{EntityBundle, EntityPlugin, HasClientLoaded, LocalEntity, Physics, Position}; use azalea_physics::PhysicsPlugin; use azalea_world::{Chunk, Instance, InstanceContainer, MinecraftEntityId, PartialInstance}; use bevy_app::App; @@ -63,6 +63,7 @@ fn test_gravity() { ), MinecraftEntityId(0), LocalEntity, + HasClientLoaded, )) .id(); { @@ -118,6 +119,7 @@ fn test_collision() { ), MinecraftEntityId(0), LocalEntity, + HasClientLoaded, )) .id(); let block_state = partial_world.chunks.set_block_state( @@ -174,6 +176,7 @@ fn test_slab_collision() { ), MinecraftEntityId(0), LocalEntity, + HasClientLoaded, )) .id(); let block_state = partial_world.chunks.set_block_state( @@ -224,6 +227,7 @@ fn test_top_slab_collision() { ), MinecraftEntityId(0), LocalEntity, + HasClientLoaded, )) .id(); let block_state = world_lock.write().chunks.set_block_state( @@ -281,6 +285,7 @@ fn test_weird_wall_collision() { ), MinecraftEntityId(0), LocalEntity, + HasClientLoaded, )) .id(); let block_state = world_lock.write().chunks.set_block_state( @@ -343,6 +348,7 @@ fn test_negative_coordinates_weird_wall_collision() { ), MinecraftEntityId(0), LocalEntity, + HasClientLoaded, )) .id(); let block_state = world_lock.write().chunks.set_block_state( @@ -409,6 +415,7 @@ fn spawn_and_unload_world() { ), MinecraftEntityId(0), LocalEntity, + HasClientLoaded, )) .id(); @@ -524,6 +531,7 @@ fn test_afk_pool() { ), MinecraftEntityId(0), LocalEntity, + HasClientLoaded, )) .id(); |
