From 833f306e8b8faddd232b5c736b2134ed08adcb6c Mon Sep 17 00:00:00 2001 From: mat <27899617+mat-1@users.noreply.github.com> Date: Fri, 21 Feb 2025 13:43:56 -0600 Subject: Fix errors on switching dimensions (#204) * Fix errors on switching dimensions * fix other tests * clippy * fix log feature in test_simulation * fix chunks oops --- azalea-physics/tests/physics.rs | 42 ++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'azalea-physics') diff --git a/azalea-physics/tests/physics.rs b/azalea-physics/tests/physics.rs index d2986ff0..c9fcdf97 100644 --- a/azalea-physics/tests/physics.rs +++ b/azalea-physics/tests/physics.rs @@ -1,12 +1,16 @@ +use std::sync::Arc; + use azalea_core::{ position::{BlockPos, ChunkPos, Vec3}, + registry_holder::RegistryHolder, resource_location::ResourceLocation, tick::GameTick, }; use azalea_entity::{EntityBundle, EntityPlugin, LocalEntity, Physics, Position}; use azalea_physics::PhysicsPlugin; -use azalea_world::{Chunk, InstanceContainer, MinecraftEntityId, PartialInstance}; +use azalea_world::{Chunk, Instance, InstanceContainer, MinecraftEntityId, PartialInstance}; use bevy_app::App; +use parking_lot::RwLock; use uuid::Uuid; /// You need an app to spawn entities in the world and do updates. @@ -17,14 +21,19 @@ fn make_test_app() -> App { app } -#[test] -fn test_gravity() { - let mut app = make_test_app(); - let world_lock = app.world_mut().resource_mut::().insert( +pub fn insert_overworld(app: &mut App) -> Arc> { + app.world_mut().resource_mut::().insert( ResourceLocation::new("minecraft:overworld"), 384, -64, - ); + &RegistryHolder::default(), + ) +} + +#[test] +fn test_gravity() { + let mut app = make_test_app(); + let world_lock = insert_overworld(&mut app); let mut partial_world = PartialInstance::default(); // the entity has to be in a loaded chunk for physics to work partial_world.chunks.set( @@ -80,11 +89,7 @@ fn test_gravity() { #[test] fn test_collision() { let mut app = make_test_app(); - let world_lock = app.world_mut().resource_mut::().insert( - ResourceLocation::new("minecraft:overworld"), - 384, - -64, - ); + let world_lock = insert_overworld(&mut app); let mut partial_world = PartialInstance::default(); partial_world.chunks.set( @@ -140,11 +145,7 @@ fn test_collision() { #[test] fn test_slab_collision() { let mut app = make_test_app(); - let world_lock = app.world_mut().resource_mut::().insert( - ResourceLocation::new("minecraft:overworld"), - 384, - -64, - ); + let world_lock = insert_overworld(&mut app); let mut partial_world = PartialInstance::default(); partial_world.chunks.set( @@ -194,11 +195,7 @@ fn test_slab_collision() { #[test] fn test_top_slab_collision() { let mut app = make_test_app(); - let world_lock = app.world_mut().resource_mut::().insert( - ResourceLocation::new("minecraft:overworld"), - 384, - -64, - ); + let world_lock = insert_overworld(&mut app); let mut partial_world = PartialInstance::default(); partial_world.chunks.set( @@ -251,6 +248,7 @@ fn test_weird_wall_collision() { ResourceLocation::new("minecraft:overworld"), 384, -64, + &RegistryHolder::default(), ); let mut partial_world = PartialInstance::default(); @@ -309,6 +307,7 @@ fn test_negative_coordinates_weird_wall_collision() { ResourceLocation::new("minecraft:overworld"), 384, -64, + &RegistryHolder::default(), ); let mut partial_world = PartialInstance::default(); @@ -371,6 +370,7 @@ fn spawn_and_unload_world() { ResourceLocation::new("minecraft:overworld"), 384, -64, + &RegistryHolder::default(), ); let mut partial_world = PartialInstance::default(); -- cgit v1.2.3