diff options
| author | Charles Johnson <32775248+ChemicalXandco@users.noreply.github.com> | 2023-02-13 16:33:51 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-13 10:33:51 -0600 |
| commit | 17463391fe708ab667ec482a336b22f5fe189002 (patch) | |
| tree | 2c8020a0598cb59187dcfd06c77d973b4fae3f1d /azalea-physics/src/lib.rs | |
| parent | 1b3d6f9581689e9caa0e2dd14dcf48c20fb06ed7 (diff) | |
| download | azalea-drasl-17463391fe708ab667ec482a336b22f5fe189002.tar.xz | |
fix `BlockCollisions` bounding box (#68)
* fix `BlockCollisions` bounding box
* add test
---------
Co-authored-by: Ubuntu <github@matdoes.dev>
Diffstat (limited to 'azalea-physics/src/lib.rs')
| -rw-r--r-- | azalea-physics/src/lib.rs | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/azalea-physics/src/lib.rs b/azalea-physics/src/lib.rs index a8eddeaa..00df7bd3 100644 --- a/azalea-physics/src/lib.rs +++ b/azalea-physics/src/lib.rs @@ -596,4 +596,65 @@ mod tests { let entity_pos = app.world.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::<WorldContainer>().insert( + ResourceLocation::new("minecraft:overworld").unwrap(), + 384, + -64, + ); + let mut partial_world = PartialWorld::default(); + + partial_world.chunks.set( + &ChunkPos { x: -1, z: -1 }, + Some(Chunk::default()), + &mut world_lock.write().chunks, + ); + let entity = app + .world + .spawn(( + EntityBundle::new( + Uuid::nil(), + Vec3 { + x: -7.5, + y: 73., + z: -7.5, + }, + azalea_registry::EntityKind::Player, + ResourceLocation::new("minecraft:overworld").unwrap(), + ), + MinecraftEntityId(0), + Local, + )) + .id(); + let block_state = world_lock.write().chunks.set_block_state( + &BlockPos { + x: -8, + y: 69, + z: -8, + }, + azalea_block::CobblestoneWallBlock { + east: azalea_block::EastWall::Low, + north: azalea_block::NorthWall::Low, + south: azalea_block::SouthWall::Low, + west: azalea_block::WestWall::Low, + up: false, + waterlogged: false, + } + .into(), + ); + assert!( + block_state.is_some(), + "Block state should exist, if this fails that means the chunk wasn't loaded and the block didn't get placed" + ); + // do a few steps so we fall on the slab + for _ in 0..20 { + app.update(); + } + + let entity_pos = app.world.get::<Position>(entity).unwrap(); + assert_eq!(entity_pos.y, 70.5); + } } |
