diff options
Diffstat (limited to 'azalea-physics/src')
| -rw-r--r-- | azalea-physics/src/collision/entity_collisions.rs | 6 | ||||
| -rw-r--r-- | azalea-physics/src/collision/mod.rs | 10 | ||||
| -rw-r--r-- | azalea-physics/src/collision/world_collisions.rs | 12 | ||||
| -rw-r--r-- | azalea-physics/src/fluids.rs | 22 | ||||
| -rw-r--r-- | azalea-physics/src/lib.rs | 36 | ||||
| -rw-r--r-- | azalea-physics/src/travel.rs | 14 |
6 files changed, 50 insertions, 50 deletions
diff --git a/azalea-physics/src/collision/entity_collisions.rs b/azalea-physics/src/collision/entity_collisions.rs index de70b2b9..5933f2d3 100644 --- a/azalea-physics/src/collision/entity_collisions.rs +++ b/azalea-physics/src/collision/entity_collisions.rs @@ -3,7 +3,7 @@ use azalea_entity::{ Physics, metadata::{AbstractBoat, Shulker}, }; -use azalea_world::Instance; +use azalea_world::World; use bevy_ecs::{ component::Component, entity::Entity, @@ -51,7 +51,7 @@ pub fn update_last_bounding_box( } pub fn get_entity_collisions( - world: &Instance, + world: &World, aabb: &Aabb, source_entity: Option<Entity>, aabb_query: &AabbQuery, @@ -83,7 +83,7 @@ pub fn get_entity_collisions( /// `source_entity` is the entity that the bounding box belongs to, and won't be /// one of the returned entities. pub fn get_entities( - world: &Instance, + world: &World, source_entity: Option<Entity>, aabb: &Aabb, predicate: &dyn Fn(Entity) -> bool, diff --git a/azalea-physics/src/collision/mod.rs b/azalea-physics/src/collision/mod.rs index f720fdba..430b91ad 100644 --- a/azalea-physics/src/collision/mod.rs +++ b/azalea-physics/src/collision/mod.rs @@ -19,7 +19,7 @@ use azalea_entity::{ metadata::Sprinting, }; use azalea_registry::builtin::BlockKind; -use azalea_world::{ChunkStorage, Instance}; +use azalea_world::{ChunkStorage, World}; use bevy_ecs::{entity::Entity, world::Mut}; pub use blocks::BlockWithShape; pub use discrete_voxel_shape::*; @@ -110,7 +110,7 @@ fn collide(ctx: &MoveCtx, movement: Vec3) -> Vec3 { pub struct MoveCtx<'world, 'state, 'a, 'b> { pub mover_type: MoverType, - pub world: &'a Instance, + pub world: &'a World, pub position: Mut<'a, Position>, pub physics: &'a mut Physics, pub source_entity: Entity, @@ -338,7 +338,7 @@ fn is_above_ground(ctx: &CanFallAtLeastCtx, max_up_step: f32) -> bool { pub struct CanFallAtLeastCtx<'world, 'state, 'a, 'b> { physics: &'a Physics, - world: &'a Instance, + world: &'a World, source_entity: Entity, aabb_query: &'a AabbQuery<'world, 'state, 'b>, collidable_entity_query: &'a CollidableEntityQuery<'world, 'state>, @@ -377,7 +377,7 @@ fn can_fall_at_least( fn collide_bounding_box( movement: Vec3, entity_bounding_box: &Aabb, - world: &Instance, + world: &World, entity_collisions: &[VoxelShape], ) -> Vec3 { let mut collision_boxes: Vec<VoxelShape> = Vec::with_capacity(entity_collisions.len() + 1); @@ -437,7 +437,7 @@ fn collide_with_shapes( /// Get the [`VoxelShape`] for the given fluid state. /// -/// The instance and position are required so it can check if the block above is +/// The world and position are required so it can check if the block above is /// also the same fluid type. pub fn fluid_shape(fluid: &FluidState, world: &ChunkStorage, pos: BlockPos) -> &'static VoxelShape { if fluid.amount == 9 { diff --git a/azalea-physics/src/collision/world_collisions.rs b/azalea-physics/src/collision/world_collisions.rs index cd883649..36a085de 100644 --- a/azalea-physics/src/collision/world_collisions.rs +++ b/azalea-physics/src/collision/world_collisions.rs @@ -7,14 +7,14 @@ use azalea_core::{ position::{BlockPos, ChunkBlockPos, ChunkPos, ChunkSectionBlockPos, ChunkSectionPos, Vec3}, }; use azalea_inventory::ItemStack; -use azalea_world::{Chunk, Instance}; +use azalea_world::{Chunk, World}; use bevy_ecs::entity::Entity; use parking_lot::RwLock; use super::{BLOCK_SHAPE, Shapes}; use crate::collision::{Aabb, BlockWithShape, VoxelShape}; -pub fn get_block_collisions(world: &Instance, aabb: &Aabb) -> Vec<VoxelShape> { +pub fn get_block_collisions(world: &World, aabb: &Aabb) -> Vec<VoxelShape> { let mut state = BlockCollisionsState::new(world, aabb, EntityCollisionContext::of(None)); let mut block_collisions = Vec::new(); @@ -34,7 +34,7 @@ pub fn get_block_collisions(world: &Instance, aabb: &Aabb) -> Vec<VoxelShape> { block_collisions } -pub fn get_block_and_liquid_collisions(world: &Instance, aabb: &Aabb) -> Vec<VoxelShape> { +pub fn get_block_and_liquid_collisions(world: &World, aabb: &Aabb) -> Vec<VoxelShape> { let mut state = BlockCollisionsState::new( world, aabb, @@ -59,7 +59,7 @@ pub fn get_block_and_liquid_collisions(world: &Instance, aabb: &Aabb) -> Vec<Vox } pub struct BlockCollisionsState<'a> { - pub world: &'a Instance, + pub world: &'a World, pub aabb: &'a Aabb, pub entity_shape: VoxelShape, pub cursor: Cursor3d, @@ -126,7 +126,7 @@ impl<'a> BlockCollisionsState<'a> { block_collisions.push(block_shape); } - pub fn new(world: &'a Instance, aabb: &'a Aabb, context: EntityCollisionContext) -> Self { + pub fn new(world: &'a World, aabb: &'a Aabb, context: EntityCollisionContext) -> Self { let origin = BlockPos { x: (aabb.min.x - EPSILON).floor() as i32 - 1, y: (aabb.min.y - EPSILON).floor() as i32 - 1, @@ -283,7 +283,7 @@ impl CanStandOnFluidPredicate { /// a performance loss for Azalea. If this ever turns out to be a bottleneck, /// then maybe you should try having it do that instead. pub fn for_entities_in_chunks_colliding_with( - world: &Instance, + world: &World, aabb: &Aabb, mut consumer: impl FnMut(ChunkPos, &HashSet<Entity>), ) { diff --git a/azalea-physics/src/fluids.rs b/azalea-physics/src/fluids.rs index fa6a1586..73ee7ddb 100644 --- a/azalea-physics/src/fluids.rs +++ b/azalea-physics/src/fluids.rs @@ -8,7 +8,7 @@ use azalea_core::{ }; use azalea_entity::{HasClientLoaded, LocalEntity, Physics, Position}; use azalea_registry::builtin::BlockKind; -use azalea_world::{Instance, InstanceContainer, InstanceName}; +use azalea_world::{World, WorldName, Worlds}; use bevy_ecs::prelude::*; use crate::collision::legacy_blocks_motion; @@ -16,13 +16,13 @@ use crate::collision::legacy_blocks_motion; #[allow(clippy::type_complexity)] pub fn update_in_water_state_and_do_fluid_pushing( mut query: Query< - (&mut Physics, &Position, &InstanceName), + (&mut Physics, &Position, &WorldName), (With<LocalEntity>, With<HasClientLoaded>), >, - instance_container: Res<InstanceContainer>, + worlds: Res<Worlds>, ) { - for (mut physics, position, instance_name) in &mut query { - let Some(world_lock) = instance_container.get(instance_name) else { + for (mut physics, position, world_name) in &mut query { + let Some(world_lock) = worlds.get(world_name) else { continue; }; let world = world_lock.read(); @@ -41,7 +41,7 @@ pub fn update_in_water_state_and_do_fluid_pushing( .registries .dimension_type .map - .get(&**instance_name) + .get(&**world_name) .and_then(|i| i.ultrawarm) .unwrap_or_default(); let lava_push_factor = if is_ultrawarm { @@ -60,7 +60,7 @@ pub fn update_in_water_state_and_do_fluid_pushing( } fn update_in_water_state_and_do_water_current_pushing( physics: &mut Physics, - world: &Instance, + world: &World, _position: Position, ) { // TODO: implement vehicles and boats @@ -86,7 +86,7 @@ fn update_in_water_state_and_do_water_current_pushing( fn update_fluid_height_and_do_fluid_pushing( physics: &mut Physics, - world: &Instance, + world: &World, checking_fluid: FluidKind, fluid_push_factor: f64, ) -> bool { @@ -180,7 +180,7 @@ pub fn update_swimming() { } // FlowingFluid.getFlow -pub fn get_fluid_flow(fluid: &FluidState, world: &Instance, pos: BlockPos) -> Vec3 { +pub fn get_fluid_flow(fluid: &FluidState, world: &World, pos: BlockPos) -> Vec3 { let mut z_flow: f64 = 0.; let mut x_flow: f64 = 0.; @@ -244,7 +244,7 @@ pub fn get_fluid_flow(fluid: &FluidState, world: &Instance, pos: BlockPos) -> Ve // i don't really get what this is for fn is_solid_face( fluid: &FluidState, - world: &Instance, + world: &World, adjacent_pos: BlockPos, direction: Direction, ) -> bool { @@ -269,7 +269,7 @@ fn is_solid_face( fn is_face_sturdy( _block_state: BlockState, - _world: &Instance, + _world: &World, _pos: BlockPos, _direction: Direction, ) -> bool { diff --git a/azalea-physics/src/lib.rs b/azalea-physics/src/lib.rs index 90c89b16..491bda0e 100644 --- a/azalea-physics/src/lib.rs +++ b/azalea-physics/src/lib.rs @@ -21,7 +21,7 @@ use azalea_entity::{ metadata::Sprinting, move_relative, }; use azalea_registry::builtin::{BlockKind, EntityKind, MobEffect}; -use azalea_world::{Instance, InstanceContainer, InstanceName}; +use azalea_world::{World, WorldName, Worlds}; use bevy_app::{App, Plugin, Update}; use bevy_ecs::prelude::*; use clip::box_traverse_blocks; @@ -71,12 +71,12 @@ pub fn ai_step( &LookDirection, &Sprinting, &ActiveEffects, - &InstanceName, + &WorldName, &EntityKindComponent, ), (With<LocalEntity>, With<HasClientLoaded>), >, - instance_container: Res<InstanceContainer>, + worlds: Res<Worlds>, ) { for ( mut physics, @@ -85,7 +85,7 @@ pub fn ai_step( look_direction, sprinting, active_effects, - instance_name, + world_name, entity_kind, ) in &mut query { @@ -147,8 +147,8 @@ pub fn ai_step( *position, *look_direction, *sprinting, - instance_name, - &instance_container, + world_name, + &worlds, active_effects, ); physics.no_jump_delay = 10; @@ -176,13 +176,13 @@ fn jump_in_liquid(physics: &mut Physics) { #[allow(clippy::type_complexity)] pub fn apply_effects_from_blocks( mut query: Query< - (&mut Physics, &Position, &EntityDimensions, &InstanceName), + (&mut Physics, &Position, &EntityDimensions, &WorldName), (With<LocalEntity>, With<HasClientLoaded>), >, - instance_container: Res<InstanceContainer>, + worlds: Res<Worlds>, ) { for (mut physics, position, dimensions, world_name) in &mut query { - let Some(world_lock) = instance_container.get(world_name) else { + let Some(world_lock) = worlds.get(world_name) else { continue; }; let world = world_lock.read(); @@ -211,7 +211,7 @@ pub fn apply_effects_from_blocks( fn check_inside_blocks( physics: &mut Physics, dimensions: &EntityDimensions, - world: &Instance, + world: &World, movements: &[EntityMovement], ) -> Vec<BlockState> { let mut blocks_inside = Vec::new(); @@ -291,7 +291,7 @@ fn collided_with_shape_moving_from( // BlockBehavior.entityInside fn handle_entity_inside_block( - world: &Instance, + world: &World, block: BlockState, block_pos: BlockPos, physics: &mut Physics, @@ -339,12 +339,12 @@ pub fn jump_from_ground( position: Position, look_direction: LookDirection, sprinting: Sprinting, - instance_name: &InstanceName, - instance_container: &InstanceContainer, + world_name: &WorldName, + worlds: &Worlds, active_effects: &ActiveEffects, ) { - let world_lock = instance_container - .get(instance_name) + let world_lock = worlds + .get(world_name) .expect("All entities should be in a valid world"); let world = world_lock.read(); @@ -436,7 +436,7 @@ fn handle_on_climbable( velocity: Vec3, on_climbable: OnClimbable, position: Position, - world: &Instance, + world: &World, pose: Option<Pose>, ) -> Vec3 { if !*on_climbable { @@ -488,7 +488,7 @@ fn get_friction_influenced_speed( /// Returns the what the entity's jump should be multiplied by based on the /// block they're standing on. -fn block_jump_factor(world: &Instance, position: Position) -> f32 { +fn block_jump_factor(world: &World, position: Position) -> f32 { let block_at_pos = world.chunks.get_block_state(position.into()); let block_below = world .chunks @@ -516,7 +516,7 @@ fn block_jump_factor(world: &Instance, position: Position) -> f32 { // public double getJumpBoostPower() { // return this.hasEffect(MobEffects.JUMP) ? (double)(0.1F * // (float)(this.getEffect(MobEffects.JUMP).getAmplifier() + 1)) : 0.0D; } -fn jump_power(world: &Instance, position: Position) -> f32 { +fn jump_power(world: &World, position: Position) -> f32 { 0.42 * block_jump_factor(world, position) } diff --git a/azalea-physics/src/travel.rs b/azalea-physics/src/travel.rs index 0b980d5a..257e2924 100644 --- a/azalea-physics/src/travel.rs +++ b/azalea-physics/src/travel.rs @@ -7,7 +7,7 @@ use azalea_entity::{ Attributes, HasClientLoaded, Jumping, LocalEntity, LookDirection, OnClimbable, Physics, PlayerAbilities, Pose, Position, metadata::Sprinting, move_relative, }; -use azalea_world::{Instance, InstanceContainer, InstanceName}; +use azalea_world::{World, WorldName, Worlds}; use bevy_ecs::prelude::*; use crate::{ @@ -29,7 +29,7 @@ pub fn travel( ( Entity, &Attributes, - &InstanceName, + &WorldName, &OnClimbable, &Jumping, Option<&PhysicsState>, @@ -42,7 +42,7 @@ pub fn travel( ), (With<LocalEntity>, With<HasClientLoaded>), >, - instance_container: Res<InstanceContainer>, + worlds: Res<Worlds>, aabb_query: AabbQuery, collidable_entity_query: CollidableEntityQuery, ) { @@ -61,7 +61,7 @@ pub fn travel( position, ) in &mut query { - let Some(world_lock) = instance_container.get(world_name) else { + let Some(world_lock) = worlds.get(world_name) else { continue; }; let world = world_lock.read(); @@ -252,7 +252,7 @@ fn get_fluid_falling_adjusted_movement( } fn is_free( - world: &Instance, + world: &World, source_entity: Entity, aabb_query: &AabbQuery, collidable_entity_query: &CollidableEntityQuery, @@ -274,7 +274,7 @@ fn is_free( } pub fn no_collision( - world: &Instance, + world: &World, source_entity: Option<Entity>, aabb_query: &AabbQuery, collidable_entity_query: &CollidableEntityQuery, @@ -323,7 +323,7 @@ fn border_collision(_entity_physics: &Physics, _aabb: &Aabb) -> Option<Aabb> { None } -fn contains_any_liquid(world: &Instance, bounding_box: Aabb) -> bool { +fn contains_any_liquid(world: &World, bounding_box: Aabb) -> bool { let min = bounding_box.min.to_block_pos_floor(); let max = bounding_box.max.to_block_pos_ceil(); |
