pub struct ChunkSection {
pub y: i8,
pub block_palette: Vec<BlockData>,
pub block_data: Option<[i64; 4096]>,
pub biome_palette: Vec<String>,
pub biome_data: Option<[i64; 64]>,
pub block_light: Option<[i8; 4096]>,
pub sky_light: Option<[i8; 4096]>,
}Expand description
Fields§
§y: i8The y position of the sector
block_palette: Vec<BlockData>A list of all used blocks in a chunk
block_data: Option<[i64; 4096]>A list of all placed blocks, the list contains the offset into the block_palette list to
save some memmory, this field is optional, if None and block_palette.len() == 1 then
the whole sections is filled with that one block.
§Example
full chunk of Air:
the block_palette contains the data for air. the block_data is None to indicate that
the same data is used accross the whole section
§Info
The stored indices are always as small as possible, but at least 4 bits with no packing accross multiple elements of the array. Meaning if the chunk consists of 33 different blocks, we need 5 bits to represent all unique blocks, now we can divide 64 by the amount of needed bits and floor the result to know how much block entries we can store per element(u64). For example $⌊64/5⌋ = 12$ so if we need 5 bits to represent each unique block we can store 12 per element.
§Note
The explanation above only applies to the nbt representation. The used on in the code has an entry for each element to keep the amount of computation low in a trade of with a bit more used memory
biome_palette: Vec<String>A list of all used biomes in the chunk
biome_data: Option<[i64; 64]>An optional list of the biomes used on each (x | z) position. If the value is None every
location in the section has the same biome
block_light: Option<[i8; 4096]>The light emitter data of each block in the chunk
§Note
In the Nbt data this will be stored as a [u8; 2048] where each element will contain two block each 4-bits of light data.
sky_light: Option<[i8; 4096]>The sky light data of each block in the chunk
§Note
In the Nbt data this will be stored as a [u8; 2048] where each element will contain two block each 4-bits of light data.
Implementations§
source§impl ChunkSection
impl ChunkSection
Trait Implementations§
source§impl AsNbtValue for ChunkSection
impl AsNbtValue for ChunkSection
source§impl Debug for ChunkSection
impl Debug for ChunkSection
source§impl FromNbtValue for ChunkSection
impl FromNbtValue for ChunkSection
source§impl PartialEq for ChunkSection
impl PartialEq for ChunkSection
source§fn eq(&self, other: &ChunkSection) -> bool
fn eq(&self, other: &ChunkSection) -> bool
self and other values to be equal, and is used
by ==.