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: McStructureSizeStructure 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
impl McStructureFile
Sourcepub fn new_air(size: McStructureSize, world_origin: [i32; 3]) -> Result<Self>
pub fn new_air(size: McStructureSize, world_origin: [i32; 3]) -> Result<Self>
Creates an empty air structure with the requested size.
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self>
pub fn from_bytes(bytes: &[u8]) -> Result<Self>
Reads a structure from uncompressed little-endian NBT bytes.
Sourcepub fn to_bytes(&self) -> Result<Vec<u8>>
pub fn to_bytes(&self) -> Result<Vec<u8>>
Serializes this structure as uncompressed little-endian NBT bytes.
Sourcepub fn read_from_path(path: &Path) -> Result<Self>
pub fn read_from_path(path: &Path) -> Result<Self>
Reads a .mcstructure file from disk.
Sourcepub fn write_to_path(&self, path: &Path) -> Result<()>
pub fn write_to_path(&self, path: &Path) -> Result<()>
Writes this structure to disk as a .mcstructure file.
Sourcepub fn primary_index_at(&self, x: i32, y: i32, z: i32) -> Result<i32>
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.
Sourcepub fn blocks(&self) -> Result<Vec<McStructureBlock>>
pub fn blocks(&self) -> Result<Vec<McStructureBlock>>
Iterates every block position in structure order.
Sourcepub fn palette_entry_or_air(&self, index: i32) -> McStructurePaletteEntry
pub fn palette_entry_or_air(&self, index: i32) -> McStructurePaletteEntry
Returns the palette entry for a structure-layer index.
Sourcepub fn index_is_air(&self, index: i32) -> bool
pub fn index_is_air(&self, index: i32) -> bool
Returns whether a structure-layer index resolves to air.
Sourcepub fn target_chunks(
&self,
placement: McStructurePlacement,
) -> Result<BTreeSet<ChunkPos>>
pub fn target_chunks( &self, placement: McStructurePlacement, ) -> Result<BTreeSet<ChunkPos>>
Computes all chunks touched by this structure placement.
Sourcepub fn write_to_world_blocking<S>(
&self,
world: &BedrockWorld<S>,
placement: McStructurePlacement,
guard: &WriteGuard,
progress: impl FnMut(McStructureWriteProgress),
) -> Result<McStructureWriteResult>where
S: WorldStorageHandle,
pub fn write_to_world_blocking<S>(
&self,
world: &BedrockWorld<S>,
placement: McStructurePlacement,
guard: &WriteGuard,
progress: impl FnMut(McStructureWriteProgress),
) -> Result<McStructureWriteResult>where
S: WorldStorageHandle,
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.
Sourcepub fn from_world_region_blocking(
world: &BedrockWorld,
dimension: Dimension,
min_x: i32,
min_y: i32,
min_z: i32,
size: McStructureSize,
) -> Result<Self>
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
impl Clone for McStructureFile
Source§fn clone(&self) -> McStructureFile
fn clone(&self) -> McStructureFile
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for McStructureFile
impl Debug for McStructureFile
Source§impl PartialEq for McStructureFile
impl PartialEq for McStructureFile
impl StructuralPartialEq for McStructureFile
Auto Trait Implementations§
impl Freeze for McStructureFile
impl RefUnwindSafe for McStructureFile
impl Send for McStructureFile
impl Sync for McStructureFile
impl Unpin for McStructureFile
impl UnsafeUnpin for McStructureFile
impl UnwindSafe for McStructureFile
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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