Skip to main content

ChunkStorageTrait

Trait ChunkStorageTrait 

Source
pub trait ChunkStorageTrait:
    Send
    + Sync
    + Any {
    // Required methods
    fn min_y(&self) -> i32;
    fn height(&self) -> u32;
    fn get(&self, pos: &ChunkPos) -> Option<Arc<RwLock<Chunk>>>;
    fn upsert(&mut self, pos: ChunkPos, chunk: Chunk) -> Arc<RwLock<Chunk>>;
    fn chunks(&self) -> Box<[&ChunkPos]>;
    fn clone_box(&self) -> Box<dyn ChunkStorageTrait>;

    // Provided methods
    fn get_block_state(&self, pos: BlockPos) -> Option<BlockState> { ... }
    fn set_block_state(
        &self,
        pos: BlockPos,
        state: BlockState,
    ) -> Option<BlockState> { ... }
    fn get_fluid_state(&self, pos: BlockPos) -> Option<FluidState> { ... }
    fn get_biome(&self, pos: BlockPos) -> Option<Biome> { ... }
}

Required Methods§

Source

fn min_y(&self) -> i32

Return the lowest y coordinate in the world, usually -64.

Source

fn height(&self) -> u32

Return the height of the world in blocks, usually 384.

Source

fn get(&self, pos: &ChunkPos) -> Option<Arc<RwLock<Chunk>>>

Return a reference to the chunk from the storage.

Source

fn upsert(&mut self, pos: ChunkPos, chunk: Chunk) -> Arc<RwLock<Chunk>>

Insert the chunk into the storage and return a reference to it.

Since the storage may be a WeakChunkStorage, you must immediately put the returned Arc<RwLock<Chunk>> somewhere (probably a PartialChunkStorage).

Source

fn chunks(&self) -> Box<[&ChunkPos]>

Source

fn clone_box(&self) -> Box<dyn ChunkStorageTrait>

Provided Methods§

Source

fn get_block_state(&self, pos: BlockPos) -> Option<BlockState>

Returns the [BlockState] at the given position.

If the block is outside of the world, then None is returned.

Source

fn set_block_state( &self, pos: BlockPos, state: BlockState, ) -> Option<BlockState>

Set a [BlockState] at the given position.

Returns the block that was previously there, or None if the position is outside of the world.

Source

fn get_fluid_state(&self, pos: BlockPos) -> Option<FluidState>

Source

fn get_biome(&self, pos: BlockPos) -> Option<Biome>

Implementors§