Skip to main content

McStructureFile

Struct McStructureFile 

Source
pub struct McStructureFile {
    pub size: McStructureSize,
    pub world_origin: [i32; 3],
    pub palette: Vec<McStructurePaletteEntry>,
    pub primary_indices: Vec<i32>,
    pub secondary_indices: Vec<i32>,
    pub entities: Vec<NbtTag>,
    pub block_position_data: IndexMap<String, NbtTag>,
}
Expand description

In-memory representation of a Bedrock .mcstructure file.

Fields§

§size: McStructureSize

Structure dimensions.

§world_origin: [i32; 3]

World origin saved in the file.

§palette: Vec<McStructurePaletteEntry>

Shared block palette.

§primary_indices: Vec<i32>

Primary block layer indices in structure order.

§secondary_indices: Vec<i32>

Secondary block layer indices in structure order.

§entities: Vec<NbtTag>

Entity NBT entries.

§block_position_data: IndexMap<String, NbtTag>

Raw block_position_data compound.

Implementations§

Source§

impl McStructureFile

Source

pub fn new_air(size: McStructureSize, world_origin: [i32; 3]) -> Result<Self>

Creates an empty air structure with the requested size.

Source

pub fn from_bytes(bytes: &[u8]) -> Result<Self>

Reads a structure from uncompressed little-endian NBT bytes.

Source

pub fn to_bytes(&self) -> Result<Vec<u8>>

Serializes this structure as uncompressed little-endian NBT bytes.

Source

pub fn read_from_path(path: &Path) -> Result<Self>

Reads a .mcstructure file from disk.

Source

pub fn write_to_path(&self, path: &Path) -> Result<()>

Writes this structure to disk as a .mcstructure file.

Source

pub fn from_nbt(root: NbtTag) -> Result<Self>

Parses a structure from its root NBT tag.

Source

pub fn to_nbt(&self) -> Result<NbtTag>

Converts this structure to a root NBT tag.

Source

pub fn primary_index_at(&self, x: i32, y: i32, z: i32) -> Result<i32>

Returns the primary-layer palette index at a relative block position.

Source

pub fn blocks(&self) -> Result<Vec<McStructureBlock>>

Iterates every block position in structure order.

Source

pub fn palette_entry_or_air(&self, index: i32) -> McStructurePaletteEntry

Returns the palette entry for a structure-layer index.

Source

pub fn index_is_air(&self, index: i32) -> bool

Returns whether a structure-layer index resolves to air.

Source

pub fn target_chunks( &self, placement: McStructurePlacement, ) -> Result<BTreeSet<ChunkPos>>

Computes all chunks touched by this structure placement.

Source

pub fn write_to_world_blocking<S>( &self, world: &BedrockWorld<S>, placement: McStructurePlacement, guard: &WriteGuard, progress: impl FnMut(McStructureWriteProgress), ) -> Result<McStructureWriteResult>

Merges this structure’s block layers into a world.

Block palette data, secondary block layers, and block-position NBT data are written. Entity placement is intentionally not performed because Bedrock actor storage requires stable UniqueID and digest updates.

Source

pub fn from_world_region_blocking( world: &BedrockWorld, dimension: Dimension, min_x: i32, min_y: i32, min_z: i32, size: McStructureSize, ) -> Result<Self>

Builds a structure by sampling decoded blocks from a world.

Trait Implementations§

Source§

impl Clone for McStructureFile

Source§

fn clone(&self) -> McStructureFile

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for McStructureFile

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for McStructureFile

Source§

fn eq(&self, other: &McStructureFile) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for McStructureFile

Auto Trait Implementations§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.