pub struct Chunk {
pub data: Box<Blob>,
pub x: u32,
pub z: u32,
}Expand description
A simple representation of a Minecraft Chunk
Fields§
§data: Box<Blob>All of the chunk data
x: u32The region x
z: u32The region z
Implementations§
Source§impl Chunk
impl Chunk
Sourcepub fn from_region(
region: &Region<'_>,
chunk_x: u32,
chunk_z: u32,
) -> Option<Chunk>
pub fn from_region( region: &Region<'_>, chunk_x: u32, chunk_z: u32, ) -> Option<Chunk>
Returns the chunk at an x,z coordinate within a Region.
§Arguments
region- The Region from which to get the Chunkchunk_x- The x coordinate within the Region of the Chunkchunk_z- The z coordinate within the Region of the Chunk
Sourcepub fn get_status(&self) -> &String
pub fn get_status(&self) -> &String
Returns a string representing the current generation state of the Chunk. ‘full’ is completely generated.
§Examples
use simple_anvil::region::Region;
let region = Region::from_file("r.0.0.mca");
let chunk = region.get_chunk(0, 0).unwrap();
if chunk.get_status() == "full" {
println!("Fully Generated!");
}Sourcepub fn get_last_update(&self) -> &i64
pub fn get_last_update(&self) -> &i64
Returns an i64 (equivalent of Java long) of the last tick at which the chunk updated.
§Examples
use simple_anvil::region::Region;
let region = Region::from_file("r.0.0.mca");
let chunk = region.get_chunk(0, 0).unwrap();
println!("{}", chunk.get_last_update());Sourcepub fn get_heightmap(&self, ignore_water: bool) -> Option<Vec<i32>>
pub fn get_heightmap(&self, ignore_water: bool) -> Option<Vec<i32>>
Returns a heightmap of the Chunk. If the Chunk is not fully generated then a None is returned.
§Arguments
ignore_water- Determines which heightmap to return, if true then a heightmap that does not take into account the water is returned (OCEAN_FLOOR), if false then the water is accounted for (WORLD_SURFACE).
§Examples
use simple_anvil::region::Region;
let region = Region::from_file("r.0.0.mca");
let chunk = region.get_chunk(0, 0).unwrap();
let heightmap = chunk.get_heightmap(false);Sourcepub fn get_biome(&self, y: i32) -> String
pub fn get_biome(&self, y: i32) -> String
Returns the String representation of the biome for a Chunk. Chunks can have different biomes at different vertical sections so use a heightmap to determine the top section if you only want the surface biome.
§Arguments
y- The y section of the chunk to get the biome of.
§Examples
use simple_anvil::region::Region;
let region = Region::from_file("r.0.0.mca");
let chunk = region.get_chunk(0, 0).unwrap();
let heightmap = chunk.get_heightmap(false);
let y = if let Some(heights) = heightmap {
heights.get(0).unwrap()
} else {
panic!("Chunk not fully generated");
}
let section_y = ((y + 64) / 16 - 4) as i8
let biome = chunk.get_biome(section_y);use simple_anvil::region::Region;
let region = Region::from_file("r.0.0.mca");
let chunk = region.get_chunk(0, 0).unwrap();
let biome = chunk.get_biome(-3);Sourcepub fn get_block(&self, x: i32, y: i32, z: i32) -> Block
pub fn get_block(&self, x: i32, y: i32, z: i32) -> Block
Returns the block at a particular x, y, z coordinate within a chunk. x and z should be the coordinates within the Chunk (0-15).
§Examples
use simple_anvil::region::Region;
let region = Region::from_file("r.0.0.mca");
let chunk = region.get_chunk(0, 0).unwrap();
let block = chunk.get_block(5, -12, 11);
println!("{}", block.id);