Chunk

Struct Chunk 

Source
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: u32

The region x

§z: u32

The region z

Implementations§

Source§

impl Chunk

Source

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 Chunk
  • chunk_x - The x coordinate within the Region of the Chunk
  • chunk_z - The z coordinate within the Region of the Chunk
Source

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!");
}
Source

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());
Source

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);
Source

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);
Source

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);

Trait Implementations§

Source§

impl Clone for Chunk

Source§

fn clone(&self) -> Chunk

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl Freeze for Chunk

§

impl RefUnwindSafe for Chunk

§

impl Send for Chunk

§

impl Sync for Chunk

§

impl Unpin for Chunk

§

impl UnwindSafe for Chunk

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.