diff options
| author | mat <git@matdoes.dev> | 2025-02-22 23:01:54 +0000 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2025-02-22 23:01:54 +0000 |
| commit | 34f53baf85fb5c7163ec5d71a8ab9d45d3f271b6 (patch) | |
| tree | 7920fec1203e8e96463a142f5f6da6164e76e684 /azalea-physics | |
| parent | bdd2fc91e11e2896d8e1c7046df247e1075bd40d (diff) | |
| download | azalea-drasl-34f53baf85fb5c7163ec5d71a8ab9d45d3f271b6.tar.xz | |
update to rust edition 2024
Diffstat (limited to 'azalea-physics')
| -rw-r--r-- | azalea-physics/src/clip.rs | 6 | ||||
| -rwxr-xr-x | azalea-physics/src/collision/mergers.rs | 2 | ||||
| -rw-r--r-- | azalea-physics/src/collision/mod.rs | 2 | ||||
| -rwxr-xr-x | azalea-physics/src/collision/shape.rs | 4 | ||||
| -rw-r--r-- | azalea-physics/src/collision/world_collisions.rs | 13 | ||||
| -rw-r--r-- | azalea-physics/src/fluids.rs | 2 | ||||
| -rw-r--r-- | azalea-physics/src/lib.rs | 14 | ||||
| -rw-r--r-- | azalea-physics/src/travel.rs | 8 |
8 files changed, 23 insertions, 28 deletions
diff --git a/azalea-physics/src/clip.rs b/azalea-physics/src/clip.rs index b6e6a9f9..ea5940a5 100644 --- a/azalea-physics/src/clip.rs +++ b/azalea-physics/src/clip.rs @@ -1,21 +1,21 @@ use std::collections::HashSet; use azalea_block::{ - fluid_state::{FluidKind, FluidState}, BlockState, + fluid_state::{FluidKind, FluidState}, }; use azalea_core::{ aabb::AABB, block_hit_result::BlockHitResult, direction::{Axis, Direction}, - math::{self, lerp, EPSILON}, + math::{self, EPSILON, lerp}, position::{BlockPos, Vec3}, }; use azalea_inventory::ItemStack; use azalea_world::ChunkStorage; use bevy_ecs::entity::Entity; -use crate::collision::{BlockWithShape, VoxelShape, EMPTY_SHAPE}; +use crate::collision::{BlockWithShape, EMPTY_SHAPE, VoxelShape}; #[derive(Debug, Clone)] pub struct ClipContext { diff --git a/azalea-physics/src/collision/mergers.rs b/azalea-physics/src/collision/mergers.rs index 85fd2826..dbe9c1e8 100755 --- a/azalea-physics/src/collision/mergers.rs +++ b/azalea-physics/src/collision/mergers.rs @@ -1,6 +1,6 @@ use std::cmp::{self, Ordering}; -use azalea_core::math::{gcd, lcm, EPSILON}; +use azalea_core::math::{EPSILON, gcd, lcm}; use super::CubePointRange; diff --git a/azalea-physics/src/collision/mod.rs b/azalea-physics/src/collision/mod.rs index 530aa47f..540cf7d4 100644 --- a/azalea-physics/src/collision/mod.rs +++ b/azalea-physics/src/collision/mod.rs @@ -6,7 +6,7 @@ mod world_collisions; use std::{ops::Add, sync::LazyLock}; -use azalea_block::{fluid_state::FluidState, BlockState}; +use azalea_block::{BlockState, fluid_state::FluidState}; use azalea_core::{ aabb::AABB, direction::Axis, diff --git a/azalea-physics/src/collision/shape.rs b/azalea-physics/src/collision/shape.rs index b0dceabb..726e62ad 100755 --- a/azalea-physics/src/collision/shape.rs +++ b/azalea-physics/src/collision/shape.rs @@ -3,12 +3,12 @@ use std::{cmp, num::NonZeroU32, sync::LazyLock}; use azalea_core::{ block_hit_result::BlockHitResult, direction::{Axis, AxisCycle, Direction}, - math::{binary_search, EPSILON}, + math::{EPSILON, binary_search}, position::{BlockPos, Vec3}, }; use super::mergers::IndexMerger; -use crate::collision::{BitSetDiscreteVoxelShape, DiscreteVoxelShape, AABB}; +use crate::collision::{AABB, BitSetDiscreteVoxelShape, DiscreteVoxelShape}; pub struct Shapes; diff --git a/azalea-physics/src/collision/world_collisions.rs b/azalea-physics/src/collision/world_collisions.rs index f0b41986..3aede743 100644 --- a/azalea-physics/src/collision/world_collisions.rs +++ b/azalea-physics/src/collision/world_collisions.rs @@ -9,8 +9,8 @@ use azalea_core::{ use azalea_world::{Chunk, Instance}; use parking_lot::RwLock; -use super::{Shapes, BLOCK_SHAPE}; -use crate::collision::{BlockWithShape, VoxelShape, AABB}; +use super::{BLOCK_SHAPE, Shapes}; +use crate::collision::{AABB, BlockWithShape, VoxelShape}; pub fn get_block_collisions(world: &Instance, aabb: AABB) -> Vec<VoxelShape> { let mut state = BlockCollisionsState::new(world, aabb); @@ -27,12 +27,11 @@ pub fn get_block_collisions(world: &Instance, aabb: AABB) -> Vec<VoxelShape> { let item_chunk_pos = ChunkPos::from(item.pos); let block_state: BlockState = if item_chunk_pos == initial_chunk_pos { - if let Some(initial_chunk) = &initial_chunk { - initial_chunk + match &initial_chunk { + Some(initial_chunk) => initial_chunk .get(&ChunkBlockPos::from(item.pos), state.world.chunks.min_y) - .unwrap_or(BlockState::AIR) - } else { - BlockState::AIR + .unwrap_or(BlockState::AIR), + _ => BlockState::AIR, } } else { state.get_block_state(item.pos) diff --git a/azalea-physics/src/fluids.rs b/azalea-physics/src/fluids.rs index 78a9d467..7a0c86a9 100644 --- a/azalea-physics/src/fluids.rs +++ b/azalea-physics/src/fluids.rs @@ -1,6 +1,6 @@ use azalea_block::{ - fluid_state::{FluidKind, FluidState}, BlockState, + fluid_state::{FluidKind, FluidState}, }; use azalea_core::{ direction::Direction, diff --git a/azalea-physics/src/lib.rs b/azalea-physics/src/lib.rs index c626dcdf..0541042c 100644 --- a/azalea-physics/src/lib.rs +++ b/azalea-physics/src/lib.rs @@ -8,15 +8,15 @@ pub mod travel; use std::collections::HashSet; -use azalea_block::{fluid_state::FluidState, properties, Block, BlockState}; +use azalea_block::{Block, BlockState, fluid_state::FluidState, properties}; use azalea_core::{ math, position::{BlockPos, Vec3}, tick::GameTick, }; use azalea_entity::{ - metadata::Sprinting, move_relative, Attributes, InLoadedChunk, Jumping, LocalEntity, - LookDirection, OnClimbable, Physics, Pose, Position, + Attributes, InLoadedChunk, Jumping, LocalEntity, LookDirection, OnClimbable, Physics, Pose, + Position, metadata::Sprinting, move_relative, }; use azalea_world::{Instance, InstanceContainer, InstanceName}; use bevy_app::{App, Plugin}; @@ -27,7 +27,7 @@ use bevy_ecs::{ world::Mut, }; use clip::box_traverse_blocks; -use collision::{move_colliding, BlockWithShape, MoverType, VoxelShape, BLOCK_SHAPE}; +use collision::{BLOCK_SHAPE, BlockWithShape, MoverType, VoxelShape, move_colliding}; /// A Bevy [`SystemSet`] for running physics that makes entities do things. #[derive(SystemSet, Debug, Hash, PartialEq, Eq, Clone)] @@ -476,11 +476,7 @@ fn get_friction_influenced_speed( speed * (0.216f32 / (friction * friction * friction)) } else { // entity.flying_speed - if is_sprinting { - 0.025999999f32 - } else { - 0.02 - } + if is_sprinting { 0.025999999f32 } else { 0.02 } } } diff --git a/azalea-physics/src/travel.rs b/azalea-physics/src/travel.rs index 08b59867..e6145c18 100644 --- a/azalea-physics/src/travel.rs +++ b/azalea-physics/src/travel.rs @@ -1,16 +1,16 @@ use azalea_block::{Block, BlockState}; use azalea_core::{aabb::AABB, position::Vec3}; use azalea_entity::{ - metadata::Sprinting, move_relative, Attributes, InLoadedChunk, Jumping, LocalEntity, - LookDirection, OnClimbable, Physics, Pose, Position, + Attributes, InLoadedChunk, Jumping, LocalEntity, LookDirection, OnClimbable, Physics, Pose, + Position, metadata::Sprinting, move_relative, }; use azalea_world::{Instance, InstanceContainer, InstanceName}; use bevy_ecs::prelude::*; use crate::{ - collision::{move_colliding, MoverType}, - get_block_pos_below_that_affects_movement, handle_relative_friction_and_calculate_movement, HandleRelativeFrictionAndCalculateMovementOpts, + collision::{MoverType, move_colliding}, + get_block_pos_below_that_affects_movement, handle_relative_friction_and_calculate_movement, }; /// Move the entity with the given acceleration while handling friction, |
