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§
Sourcefn get(&self, pos: &ChunkPos) -> Option<Arc<RwLock<Chunk>>>
fn get(&self, pos: &ChunkPos) -> Option<Arc<RwLock<Chunk>>>
Return a reference to the chunk from the storage.
Sourcefn upsert(&mut self, pos: ChunkPos, chunk: Chunk) -> Arc<RwLock<Chunk>>
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).
fn chunks(&self) -> Box<[&ChunkPos]>
fn clone_box(&self) -> Box<dyn ChunkStorageTrait>
Provided Methods§
Sourcefn get_block_state(&self, pos: BlockPos) -> Option<BlockState>
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.
Sourcefn set_block_state(
&self,
pos: BlockPos,
state: BlockState,
) -> Option<BlockState>
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.