diff options
| author | Ubuntu <github@matdoes.dev> | 2022-08-31 20:16:39 +0000 |
|---|---|---|
| committer | Ubuntu <github@matdoes.dev> | 2022-08-31 20:16:39 +0000 |
| commit | 7a159bdee50146ced2a0026124e4d5b62356b0f7 (patch) | |
| tree | 90421b309882d038f2b6f5b2e79f1fc21180c5eb | |
| parent | e0cbf68df1903aafaa5a08b7c167465849e093a0 (diff) | |
| download | azalea-drasl-7a159bdee50146ced2a0026124e4d5b62356b0f7.tar.xz | |
add collision test
| -rw-r--r-- | azalea-physics/src/lib.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/azalea-physics/src/lib.rs b/azalea-physics/src/lib.rs index e1c585e7..c2aa607a 100644 --- a/azalea-physics/src/lib.rs +++ b/azalea-physics/src/lib.rs @@ -173,4 +173,29 @@ mod tests { entity.pos().y ); } + #[test] + fn test_collision() { + let mut dim = Dimension::default(); + + dim.add_entity( + 0, + EntityData::new( + Uuid::from_u128(0), + Vec3 { + x: 0.5, + y: 70., + z: 0.5, + }, + ), + ); + dim.set_block_state(&BlockPos { x: 0, y: 68, z: 0 }, BlockState::Stone); + let mut entity = dim.entity_mut(0).unwrap(); + entity.ai_step(); + // delta will change, but it won't move until next tick + assert_eq!(entity.pos().y, 70.); + assert!(entity.delta.y < 0.); + entity.ai_step(); + // the second tick applies the delta to the position, but it also does collision + assert_eq!(entity.pos().y, 70.); + } } |
