Trait PieceContext
pub trait PieceContext {
Show 13 methods
// Required methods
fn metadata(&self) -> &dyn BlockMetadata;
fn chunk(&self) -> ChunkPos;
fn chunk_box(&self) -> BoundingBox;
fn random(&mut self) -> &mut dyn StructureRandom;
fn state(&self, block: BlockKey) -> BlockState;
fn state_with(
&self,
block: BlockKey,
properties: &[(&str, &str)],
) -> BlockState;
fn is_air(&self, state: BlockState) -> bool;
fn block(&mut self, pos: [i32; 3]) -> Option<BlockState>;
fn set_block(&mut self, pos: [i32; 3], state: BlockState) -> bool;
fn height(&mut self, kind: HeightmapType, x: i32, z: i32) -> Option<i32>;
fn solid_render(&self, state: BlockState) -> bool;
fn entity(&mut self, nbt: BTreeMap<JavaString, Tag>);
fn block_entity(&mut self, pos: [i32; 3], nbt: BTreeMap<JavaString, Tag>);
}Expand description
The placement context a piece’s
post_process and a type’s
after_place see: the blocks and entities of
one chunk, the piece’s random and what the blocks around it are made of.
Required Methods§
fn metadata(&self) -> &dyn BlockMetadata
fn metadata(&self) -> &dyn BlockMetadata
Immutable block metadata for this worker’s resource snapshot.
fn chunk_box(&self) -> BoundingBox
fn chunk_box(&self) -> BoundingBox
The writable box: a set_block outside it is dropped silently.
fn random(&mut self) -> &mut dyn StructureRandom
fn random(&mut self) -> &mut dyn StructureRandom
The piece’s random (RandomSource of postProcess).
fn state(&self, block: BlockKey) -> BlockState
fn state(&self, block: BlockKey) -> BlockState
The block’s default state; resolve it once when constructing or loading a piece.
fn state_with(&self, block: BlockKey, properties: &[(&str, &str)]) -> BlockState
fn state_with(&self, block: BlockKey, properties: &[(&str, &str)]) -> BlockState
A block state with partial properties; missing properties keep defaults. Resolve once at piece construction or load, never once per placed block.
fn is_air(&self, state: BlockState) -> bool
fn is_air(&self, state: BlockState) -> bool
BlockState.isAir.
fn block(&mut self, pos: [i32; 3]) -> Option<BlockState>
fn block(&mut self, pos: [i32; 3]) -> Option<BlockState>
The block at pos, or None outside the region.
fn set_block(&mut self, pos: [i32; 3], state: BlockState) -> bool
fn set_block(&mut self, pos: [i32; 3], state: BlockState) -> bool
StructurePiece.placeBlock: write state at pos, answering whether
it was written. A position outside chunk_box is skipped silently, as
vanilla’s placeBlock skips it.
fn height(&mut self, kind: HeightmapType, x: i32, z: i32) -> Option<i32>
fn height(&mut self, kind: HeightmapType, x: i32, z: i32) -> Option<i32>
WorldGenLevel.getHeight of the heightmap kind at (x, z).
fn solid_render(&self, state: BlockState) -> bool
fn solid_render(&self, state: BlockState) -> bool
BlockState.isSolidRender of a state: whether the block draws as a
solid block, the way StructurePiece.reorient asks of its neighbours.
fn entity(&mut self, nbt: BTreeMap<JavaString, Tag>)
fn entity(&mut self, nbt: BTreeMap<JavaString, Tag>)
WorldGenLevel.addFreshEntity: an entity from its saved NBT — its
id, Pos and fields — which the generating chunk holds and the game
finishes as it does a structure mob’s when the chunk joins the world
(Mob.finalizeSpawn with STRUCTURE; keep the
"horizon:finalize" byte a structure template’s entities carry to ask
for it).
fn block_entity(&mut self, pos: [i32; 3], nbt: BTreeMap<JavaString, Tag>)
fn block_entity(&mut self, pos: [i32; 3], nbt: BTreeMap<JavaString, Tag>)
WorldGenLevel.setBlockEntity at pos: the block entity’s saved NBT
(its id and fields).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".