Skip to main content

StructureType

Trait StructureType 

pub trait StructureType:
    Send
    + Sync
    + 'static {
    // Required methods
    fn find_generation_point(
        &self,
        context: &mut dyn GenerationContext,
    ) -> Option<FoundStructure>;
    fn load_piece(
        &self,
        metadata: &dyn BlockMetadata,
        tag: &BTreeMap<JavaString, Tag>,
    ) -> Result<Arc<dyn StructurePiece>, StructureError>;

    // Provided method
    fn after_place(
        &self,
        _context: &mut dyn PieceContext,
        _pieces: &[BoundingBox],
    ) -> Result<(), StructureError> { ... }
}
Expand description

A mod’s structure type: vanilla’s StructureType, whose code answers for a data pack structure with "type": "modid:tower". Implemented once, kept by the game; deterministic and stateless.

Required Methods§

fn find_generation_point( &self, context: &mut dyn GenerationContext, ) -> Option<FoundStructure>

Structure.findGenerationPoint with generatePieces: the start’s position and its pieces for the chunk context names, or None for “no start in this chunk”. The height and biome queries the context answers are the ones vanilla’s own types ask of a GenerationContext; context.config lends its NBT config, converted once at load.

fn load_piece( &self, metadata: &dyn BlockMetadata, tag: &BTreeMap<JavaString, Tag>, ) -> Result<Arc<dyn StructurePiece>, StructureError>

The StructurePieceType loader: rebuild a saved piece from its tag (StructurePieceType.load), exactly as it was saved. Required: every piece type has its loader, and a saved piece is never regenerated. Resolve saved block states once here, against the same retained metadata the worker contexts borrow. Invalid saved blocks, properties or piece data return a typed error, never a panic.

Provided Methods§

fn after_place( &self, _context: &mut dyn PieceContext, _pieces: &[BoundingBox], ) -> Result<(), StructureError>

Structure.afterPlace, run once per chunk after all pieces were placed, with every piece’s current box. Optional: most types place nothing here.

Trait Implementations§

§

impl Wire for Box<dyn StructureType>

§

const MIN: usize = 8

Minimum encoded size, used to reject impossible collection lengths.
§

fn put(&self, out: &mut Writer)

Encodes this value, recording failures on the writer.
§

fn put_owned(self, out: &mut Writer)

Consumes owned data when a resource’s ownership must cross the boundary.
§

fn take(input: &mut Reader<'_>) -> Result<Box<dyn StructureType>, WireError>

Decodes one value, leaving any following bytes for the caller.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§