aboutsummaryrefslogtreecommitdiff
path: root/azalea-physics
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2025-02-21 13:43:56 -0600
committerGitHub <noreply@github.com>2025-02-21 13:43:56 -0600
commit833f306e8b8faddd232b5c736b2134ed08adcb6c (patch)
tree08a59009f3118d5c56891d6c4fb6a0293aa9e6fc /azalea-physics
parent63b1036a96c45b0fefc6ca2501f1cc479acc95de (diff)
downloadazalea-drasl-833f306e8b8faddd232b5c736b2134ed08adcb6c.tar.xz
Fix errors on switching dimensions (#204)
* Fix errors on switching dimensions * fix other tests * clippy * fix log feature in test_simulation * fix chunks oops
Diffstat (limited to 'azalea-physics')
-rw-r--r--azalea-physics/tests/physics.rs42
1 files changed, 21 insertions, 21 deletions
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::<InstanceContainer>().insert(
+pub fn insert_overworld(app: &mut App) -> Arc<RwLock<Instance>> {
+ app.world_mut().resource_mut::<InstanceContainer>().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::<InstanceContainer>().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::<InstanceContainer>().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::<InstanceContainer>().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();