pub struct PartialChunkStorage { /* private fields */ }Expand description
An efficient storage of chunks for a client that has a limited render distance.
This has support for using a shared ChunkStorage.
Implementations§
Source§impl PartialChunkStorage
impl PartialChunkStorage
pub fn new(chunk_radius: u32) -> Self
Sourcepub fn update_view_center(&mut self, view_center: ChunkPos)
pub fn update_view_center(&mut self, view_center: ChunkPos)
Update the chunk to center the view on.
This should be called when the client receives a SetChunkCacheCenter
packet.
Sourcepub fn view_center(&self) -> ChunkPos
pub fn view_center(&self) -> ChunkPos
Get the center of the view. This is usually the chunk that the player is in.
pub fn view_range(&self) -> u32
pub fn index_from_chunk_pos(&self, chunk_pos: &ChunkPos) -> usize
pub fn chunk_pos_from_index(&self, index: usize) -> ChunkPos
pub fn in_range(&self, chunk_pos: &ChunkPos) -> bool
pub fn set_block_state( &self, pos: BlockPos, state: BlockState, chunk_storage: &ChunkStorage, ) -> Option<BlockState>
pub fn replace_with_packet_data( &mut self, pos: &ChunkPos, data: &mut Cursor<&[u8]>, heightmaps: &[(HeightmapKind, Box<[u64]>)], chunk_storage: &mut ChunkStorage, ) -> Result<(), BufReadError>
Sourcepub fn limited_get(&self, pos: &ChunkPos) -> Option<&Arc<RwLock<Chunk>>>
pub fn limited_get(&self, pos: &ChunkPos) -> Option<&Arc<RwLock<Chunk>>>
Get a Chunk within render distance, or None if it’s not loaded.
Use ChunkStorageTrait::get to get a chunk from the shared storage.
Sourcepub fn limited_get_mut(
&mut self,
pos: &ChunkPos,
) -> Option<&mut Option<Arc<RwLock<Chunk>>>>
pub fn limited_get_mut( &mut self, pos: &ChunkPos, ) -> Option<&mut Option<Arc<RwLock<Chunk>>>>
Get a mutable reference to a Chunk within render distance, or
None if it’s not loaded.
Use ChunkStorageTrait::get to get a chunk from the shared storage.
Sourcepub fn set(
&mut self,
pos: &ChunkPos,
chunk: Option<Chunk>,
chunk_storage: &mut ChunkStorage,
)
pub fn set( &mut self, pos: &ChunkPos, chunk: Option<Chunk>, chunk_storage: &mut ChunkStorage, )
Set a chunk in the shared storage and reference it from the limited storage.
Use Self::limited_set if you already have an Arc<RwLock<Chunk>>.
§Panics
If the chunk is not in the render distance.
Trait Implementations§
Source§impl Debug for PartialChunkStorage
impl Debug for PartialChunkStorage
Auto Trait Implementations§
impl Freeze for PartialChunkStorage
impl !RefUnwindSafe for PartialChunkStorage
impl Send for PartialChunkStorage
impl Sync for PartialChunkStorage
impl Unpin for PartialChunkStorage
impl UnsafeUnpin for PartialChunkStorage
impl !UnwindSafe for PartialChunkStorage
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> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
Source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self using default().