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>
impl Dimension<RegionFile>
Source§impl<R> Dimension<R>where
R: RegionParser,
impl<R> Dimension<R>where
R: RegionParser,
Sourcepub fn from_iter<I>(id: Option<DimensionID>, iter: I) -> Selfwhere
I: Iterator<Item = R>,
pub fn from_iter<I>(id: Option<DimensionID>, iter: I) -> Selfwhere
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.
Sourcepub fn has_region(&self, region_x: i32, region_z: i32) -> bool
pub fn has_region(&self, region_x: i32, region_z: i32) -> bool
Check if this dimension has a region at this location
Sourcepub fn parse_region(
&self,
region_x: i32,
region_z: i32,
) -> Result<RegionRef<'_>>
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.
Sourcepub fn regions(&self) -> impl Iterator<Item = &R>
pub fn regions(&self) -> impl Iterator<Item = &R>
Get an iterator over the RegionParser
s contained in this Dimension
Sourcepub fn locations(&self) -> impl Iterator<Item = &(i32, i32)>
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).
Sourcepub fn get_region_from_chunk(
&self,
chunk_x: i32,
chunk_z: i32,
) -> Result<Option<RegionRef<'_>>>
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 existOk(Some(Region))
if the region exists and parsed successfullyErr(_)
if the region failed to parse
Sourcepub fn get_chunk_in_world(
&self,
chunk_x: i32,
chunk_z: i32,
) -> Result<Option<ParsedChunk>>
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 existOk(Some(ParsedChunk))
if everything parsed successfullyErr(_)
if the region/chunk failed to parse