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: &NbtCompound, 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 ChunkStorage::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 ChunkStorage::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 !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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Self
using data from the given [World
].