1
2
Fork 0
mirror of https://github.com/mat-1/azalea.git synced 2025-08-02 23:44:38 +00:00

make collision test work*

This commit is contained in:
Ubuntu 2022-09-02 17:22:15 +00:00
commit 1dec4f5664
2 changed files with 15 additions and 3 deletions

View file

@ -140,7 +140,8 @@ fn get_speed(entity: &EntityData, friction: f32) -> f32 {
#[cfg(test)]
mod tests {
use super::*;
use azalea_world::Dimension;
use azalea_core::ChunkPos;
use azalea_world::{Chunk, Dimension};
use uuid::Uuid;
#[test]
@ -176,7 +177,8 @@ mod tests {
#[test]
fn test_collision() {
let mut dim = Dimension::default();
dim.set_chunk(&ChunkPos { x: 0, z: 0 }, Some(Chunk::default()))
.unwrap();
dim.add_entity(
0,
EntityData::new(
@ -188,7 +190,12 @@ mod tests {
},
),
);
dim.set_block_state(&BlockPos { x: 0, y: 68, z: 0 }, BlockState::Stone);
let old_block_state =
dim.set_block_state(&BlockPos { x: 0, y: 70, z: 0 }, BlockState::Stone);
assert!(
old_block_state.is_some(),
"Old block state should exist, if this fails that means the chunk wasn't loaded and the block didn't get placed"
);
let mut entity = dim.entity_mut(0).unwrap();
entity.ai_step();
// delta will change, but it won't move until next tick

View file

@ -52,6 +52,11 @@ impl Dimension {
self.chunk_storage.replace_with_packet_data(pos, data)
}
pub fn set_chunk(&mut self, pos: &ChunkPos, chunk: Option<Chunk>) -> Result<(), BufReadError> {
self[pos] = chunk.map(|c| Arc::new(Mutex::new(c)));
Ok(())
}
pub fn update_view_center(&mut self, pos: &ChunkPos) {
self.chunk_storage.view_center = *pos;
}