aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--azalea-physics/src/lib.rs25
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.);
+ }
}