Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Commit

Permalink
change test calls
Browse files Browse the repository at this point in the history
  • Loading branch information
DimitriTimoz committed Dec 28, 2023
1 parent d5d226b commit 05ceb8e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 5 additions & 4 deletions minecraft-server/src/world/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -662,16 +662,17 @@ mod tests {
}

// Test single block
world.map.set_block(BlockPosition { x: -40, y: -40, z: -40 }, BlockWithState::RedstoneBlock).await;
world.set_block(BlockPosition { x: -40, y: -40, z: -40 }, BlockWithState::RedstoneBlock).await;
let block = world.map.get_block(BlockPosition { x: -40, y: -40, z: -40 }).await;
assert_eq!(block.block_state_id().unwrap(), BlockWithState::RedstoneBlock.block_state_id().unwrap());

// Test no skylight at the same position
assert_eq!(world.get_light_level(BlockPosition { x: -40, y: -40, z: -40 }).await, 0);
// Set blocks
let mut id = 1;
for x in (-40..40).step_by(9) {
for y in (-40..200).step_by(15) {
for z in (-40..40).step_by(9) {
world.map.set_block(BlockPosition { x, y, z }, BlockWithState::from_state_id(id).unwrap()).await;
world.set_block(BlockPosition { x, y, z }, BlockWithState::from_state_id(id).unwrap()).await;
id += 1;
}
}
Expand All @@ -682,7 +683,7 @@ mod tests {
for x in (-40..40).step_by(9) {
for y in (-40..200).step_by(15) {
for z in (-40..40).step_by(9) {
let got = world.map.get_block(BlockPosition { x, y, z }).await.block_state_id().unwrap();
let got = world.get_block(BlockPosition { x, y, z }).await.unwrap().block_state_id().unwrap();
assert_eq!(id, got);
id += 1;
}
Expand Down
4 changes: 4 additions & 0 deletions minecraft-server/src/world/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ impl World {
self.map.get_network_chunk_column_data(position).await
}

pub async fn get_light_level(&'static self, position: BlockPosition) -> u8 {
LightManager::new(&self.map).get_light_level(LightPosition::from(position)).await
}

}

#[cfg(test)]
Expand Down

0 comments on commit 05ceb8e

Please sign in to comment.