Struct Dimension

Source
pub struct Dimension<R> {
    pub id: Option<DimensionID>,
    /* private fields */
}
Expand description

Represents a Dimension in a Minecraft world

Fields§

§id: Option<DimensionID>

The ID for the dimension, see DimensionID

Implementations§

Source§

impl Dimension<RegionFile>

Source

pub fn from_path<P>(path: P) -> Result<Self>
where P: AsRef<Path>,

Create a dimension from a path to a directory, the directory’s name is used to get the id if it is in the form of DIM{id}.

Source§

impl<R> Dimension<R>
where R: RegionParser,

Source

pub fn from_iter<I>(id: Option<DimensionID>, iter: I) -> Self
where I: Iterator<Item = R>,

Construct a Dimension from an iterator which yields items which implement the RegionParser trait.

Every parser in the iterator must be able to determine a position, otherwise this call will panic.

Note: this call consumes the iterator, but does not call RegionParser::parse on the items.

Source

pub fn has_region(&self, region_x: i32, region_z: i32) -> bool

Check if this dimension has a region at this location

Source

pub fn parse_region( &self, region_x: i32, region_z: i32, ) -> Result<RegionRef<'_>>

Parse a region file at the given location (using region coordinates)

§Panics

If the region does not exist in this Dimension, use Dimension::has_region to check before making a call to this method.

Source

pub fn regions(&self) -> impl Iterator<Item = &R>

Get an iterator over the RegionParsers contained in this Dimension

Source

pub fn locations(&self) -> impl Iterator<Item = &(i32, i32)>

Get an iterator over the locations of regions in this Dimension in the format of (x, z).

Source

pub fn get_region_from_chunk( &self, chunk_x: i32, chunk_z: i32, ) -> Result<Option<RegionRef<'_>>>

Get a region from an absolute chunk location (i.e. the “Chunk:” line in the F3 screen)

§Return Values
  • Ok(None) if the region does not exist
  • Ok(Some(Region)) if the region exists and parsed successfully
  • Err(_) if the region failed to parse
Source

pub fn get_chunk_in_world( &self, chunk_x: i32, chunk_z: i32, ) -> Result<Option<ParsedChunk>>

Get a chunk from an absolute chunk location (i.e. the “Chunk:” line in the F3 screen)

Note: This is only recommended if you only need one chunk from this region, otherwise, you should use Dimension::parse_region, Region::get_chunk, and Chunk::parse. Using those methods over this one also allows for more fine-grained control over error handling.

§Return Values
  • Ok(None) if the region does not exist
  • Ok(Some(ParsedChunk)) if everything parsed successfully
  • Err(_) if the region/chunk failed to parse

Auto Trait Implementations§

§

impl<R> Freeze for Dimension<R>

§

impl<R> RefUnwindSafe for Dimension<R>
where R: RefUnwindSafe,

§

impl<R> Send for Dimension<R>
where R: Send,

§

impl<R> Sync for Dimension<R>
where R: Sync,

§

impl<R> Unpin for Dimension<R>
where R: Unpin,

§

impl<R> UnwindSafe for Dimension<R>
where R: UnwindSafe,

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> 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, 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.