aboutsummaryrefslogtreecommitdiff
path: root/azalea-world/src
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-06-25 14:24:56 -0500
committermat <github@matdoes.dev>2022-06-25 14:24:56 -0500
commit77980f0018eca3a192994021b76ad5d05bff88ea (patch)
tree8a7ad1337f21542f1dbe098057b1e4e156df976c /azalea-world/src
parentcd9a05e5a62190b3d4a2a733bf637d6324aec5fd (diff)
downloadazalea-drasl-77980f0018eca3a192994021b76ad5d05bff88ea.tar.xz
rename World to dimension
A world is a collection of dimensions
Diffstat (limited to 'azalea-world/src')
-rw-r--r--azalea-world/src/chunk.rs15
-rw-r--r--azalea-world/src/lib.rs11
2 files changed, 15 insertions, 11 deletions
diff --git a/azalea-world/src/chunk.rs b/azalea-world/src/chunk.rs
index a19ece8c..e4893ace 100644
--- a/azalea-world/src/chunk.rs
+++ b/azalea-world/src/chunk.rs
@@ -1,6 +1,6 @@
use crate::palette::PalettedContainer;
use crate::palette::PalettedContainerType;
-use crate::World;
+use crate::Dimension;
use azalea_block::BlockState;
use azalea_buf::{McBufReadable, McBufWritable};
use azalea_core::{BlockPos, ChunkBlockPos, ChunkPos, ChunkSectionBlockPos};
@@ -78,7 +78,7 @@ impl ChunkStorage {
return Ok(());
}
- let chunk = Arc::new(Mutex::new(Chunk::read_with_world_height(
+ let chunk = Arc::new(Mutex::new(Chunk::read_with_dimension_height(
data,
self.height,
)?));
@@ -109,12 +109,15 @@ pub struct Chunk {
}
impl Chunk {
- pub fn read_with_world(buf: &mut impl Read, data: &World) -> Result<Self, String> {
- Self::read_with_world_height(buf, data.height())
+ pub fn read_with_dimension(buf: &mut impl Read, data: &Dimension) -> Result<Self, String> {
+ Self::read_with_dimension_height(buf, data.height())
}
- pub fn read_with_world_height(buf: &mut impl Read, world_height: u32) -> Result<Self, String> {
- let section_count = world_height / SECTION_HEIGHT;
+ pub fn read_with_dimension_height(
+ buf: &mut impl Read,
+ dimension_height: u32,
+ ) -> Result<Self, String> {
+ let section_count = dimension_height / SECTION_HEIGHT;
let mut sections = Vec::with_capacity(section_count as usize);
for _ in 0..section_count {
let section = Section::read_from(buf)?;
diff --git a/azalea-world/src/lib.rs b/azalea-world/src/lib.rs
index 3afa4fee..7822dcc4 100644
--- a/azalea-world/src/lib.rs
+++ b/azalea-world/src/lib.rs
@@ -27,15 +27,16 @@ mod tests {
}
}
+/// A dimension is a collection of chunks and entities.
#[derive(Debug)]
-pub struct World {
+pub struct Dimension {
chunk_storage: ChunkStorage,
entity_storage: EntityStorage,
}
-impl World {
+impl Dimension {
pub fn new(chunk_radius: u32, height: u32, min_y: i32) -> Self {
- World {
+ Dimension {
chunk_storage: ChunkStorage::new(chunk_radius, height, min_y),
entity_storage: EntityStorage::new(),
}
@@ -135,14 +136,14 @@ impl World {
}
}
-impl Index<&ChunkPos> for World {
+impl Index<&ChunkPos> for Dimension {
type Output = Option<Arc<Mutex<Chunk>>>;
fn index(&self, pos: &ChunkPos) -> &Self::Output {
&self.chunk_storage[pos]
}
}
-impl IndexMut<&ChunkPos> for World {
+impl IndexMut<&ChunkPos> for Dimension {
fn index_mut<'a>(&'a mut self, pos: &ChunkPos) -> &'a mut Self::Output {
&mut self.chunk_storage[pos]
}