diff options
Diffstat (limited to 'azalea-physics/src')
| -rw-r--r-- | azalea-physics/src/lib.rs | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/azalea-physics/src/lib.rs b/azalea-physics/src/lib.rs index 998fb300..c50095e4 100644 --- a/azalea-physics/src/lib.rs +++ b/azalea-physics/src/lib.rs @@ -440,7 +440,7 @@ mod tests { #[test] fn test_gravity() { let mut app = make_test_app(); - let world_lock = app.world.resource_mut::<InstanceContainer>().insert( + let world_lock = app.world_mut().resource_mut::<InstanceContainer>().insert( ResourceLocation::new("minecraft:overworld"), 384, -64, @@ -454,7 +454,7 @@ mod tests { ); let entity = app - .world + .world_mut() .spawn(( EntityBundle::new( Uuid::nil(), @@ -471,24 +471,24 @@ mod tests { )) .id(); { - let entity_pos = *app.world.get::<Position>(entity).unwrap(); + let entity_pos = *app.world_mut().get::<Position>(entity).unwrap(); // y should start at 70 assert_eq!(entity_pos.y, 70.); } app.update(); - app.world.run_schedule(GameTick); + app.world_mut().run_schedule(GameTick); app.update(); { - let entity_pos = *app.world.get::<Position>(entity).unwrap(); + let entity_pos = *app.world_mut().get::<Position>(entity).unwrap(); // delta is applied before gravity, so the first tick only sets the delta assert_eq!(entity_pos.y, 70.); - let entity_physics = app.world.get::<Physics>(entity).unwrap(); + let entity_physics = app.world_mut().get::<Physics>(entity).unwrap(); assert!(entity_physics.velocity.y < 0.); } - app.world.run_schedule(GameTick); + app.world_mut().run_schedule(GameTick); app.update(); { - let entity_pos = *app.world.get::<Position>(entity).unwrap(); + let entity_pos = *app.world_mut().get::<Position>(entity).unwrap(); // the second tick applies the delta to the position, so now it should go down assert!( entity_pos.y < 70., @@ -500,7 +500,7 @@ mod tests { #[test] fn test_collision() { let mut app = make_test_app(); - let world_lock = app.world.resource_mut::<InstanceContainer>().insert( + let world_lock = app.world_mut().resource_mut::<InstanceContainer>().insert( ResourceLocation::new("minecraft:overworld"), 384, -64, @@ -513,7 +513,7 @@ mod tests { &mut world_lock.write().chunks, ); let entity = app - .world + .world_mut() .spawn(( EntityBundle::new( Uuid::nil(), @@ -539,19 +539,19 @@ mod tests { "Block state should exist, if this fails that means the chunk wasn't loaded and the block didn't get placed" ); app.update(); - app.world.run_schedule(GameTick); + app.world_mut().run_schedule(GameTick); app.update(); { - let entity_pos = *app.world.get::<Position>(entity).unwrap(); + let entity_pos = *app.world_mut().get::<Position>(entity).unwrap(); // delta will change, but it won't move until next tick assert_eq!(entity_pos.y, 70.); - let entity_physics = app.world.get::<Physics>(entity).unwrap(); + let entity_physics = app.world_mut().get::<Physics>(entity).unwrap(); assert!(entity_physics.velocity.y < 0.); } - app.world.run_schedule(GameTick); + app.world_mut().run_schedule(GameTick); app.update(); { - let entity_pos = *app.world.get::<Position>(entity).unwrap(); + let entity_pos = *app.world_mut().get::<Position>(entity).unwrap(); // the second tick applies the delta to the position, but it also does collision assert_eq!(entity_pos.y, 70.); } @@ -560,7 +560,7 @@ mod tests { #[test] fn test_slab_collision() { let mut app = make_test_app(); - let world_lock = app.world.resource_mut::<InstanceContainer>().insert( + let world_lock = app.world_mut().resource_mut::<InstanceContainer>().insert( ResourceLocation::new("minecraft:overworld"), 384, -64, @@ -573,7 +573,7 @@ mod tests { &mut world_lock.write().chunks, ); let entity = app - .world + .world_mut() .spawn(( EntityBundle::new( Uuid::nil(), @@ -604,17 +604,17 @@ mod tests { ); // do a few steps so we fall on the slab for _ in 0..20 { - app.world.run_schedule(GameTick); + app.world_mut().run_schedule(GameTick); app.update(); } - let entity_pos = app.world.get::<Position>(entity).unwrap(); + let entity_pos = app.world_mut().get::<Position>(entity).unwrap(); assert_eq!(entity_pos.y, 69.5); } #[test] fn test_top_slab_collision() { let mut app = make_test_app(); - let world_lock = app.world.resource_mut::<InstanceContainer>().insert( + let world_lock = app.world_mut().resource_mut::<InstanceContainer>().insert( ResourceLocation::new("minecraft:overworld"), 384, -64, @@ -627,7 +627,7 @@ mod tests { &mut world_lock.write().chunks, ); let entity = app - .world + .world_mut() .spawn(( EntityBundle::new( Uuid::nil(), @@ -657,17 +657,17 @@ mod tests { ); // do a few steps so we fall on the slab for _ in 0..20 { - app.world.run_schedule(GameTick); + app.world_mut().run_schedule(GameTick); app.update(); } - let entity_pos = app.world.get::<Position>(entity).unwrap(); + let entity_pos = app.world_mut().get::<Position>(entity).unwrap(); assert_eq!(entity_pos.y, 70.); } #[test] fn test_weird_wall_collision() { let mut app = make_test_app(); - let world_lock = app.world.resource_mut::<InstanceContainer>().insert( + let world_lock = app.world_mut().resource_mut::<InstanceContainer>().insert( ResourceLocation::new("minecraft:overworld"), 384, -64, @@ -680,7 +680,7 @@ mod tests { &mut world_lock.write().chunks, ); let entity = app - .world + .world_mut() .spawn(( EntityBundle::new( Uuid::nil(), @@ -714,18 +714,18 @@ mod tests { ); // do a few steps so we fall on the wall for _ in 0..20 { - app.world.run_schedule(GameTick); + app.world_mut().run_schedule(GameTick); app.update(); } - let entity_pos = app.world.get::<Position>(entity).unwrap(); + let entity_pos = app.world_mut().get::<Position>(entity).unwrap(); assert_eq!(entity_pos.y, 70.5); } #[test] fn test_negative_coordinates_weird_wall_collision() { let mut app = make_test_app(); - let world_lock = app.world.resource_mut::<InstanceContainer>().insert( + let world_lock = app.world_mut().resource_mut::<InstanceContainer>().insert( ResourceLocation::new("minecraft:overworld"), 384, -64, @@ -738,7 +738,7 @@ mod tests { &mut world_lock.write().chunks, ); let entity = app - .world + .world_mut() .spawn(( EntityBundle::new( Uuid::nil(), @@ -776,11 +776,11 @@ mod tests { ); // do a few steps so we fall on the wall for _ in 0..20 { - app.world.run_schedule(GameTick); + app.world_mut().run_schedule(GameTick); app.update(); } - let entity_pos = app.world.get::<Position>(entity).unwrap(); + let entity_pos = app.world_mut().get::<Position>(entity).unwrap(); assert_eq!(entity_pos.y, 70.5); } } |
