pub struct WeakChunkStorage {
pub height: u32,
pub min_y: i32,
pub map: IntMap<ChunkPos, Weak<RwLock<Chunk>>>,
}Expand description
A storage for chunks where they’re only stored weakly, so if they’re not actively being used somewhere else they’ll be forgotten.
This is used for shared worlds.
This is relatively cheap to clone since it’s just an IntMap with Weak
pointers.
Fields§
§height: u32The height of the world.
To get the maximum y position (exclusive), you have to combine this with
Self::min_y.
min_y: i32The lowest y position in the world that can still have blocks placed on it.
This exists because in modern Minecraft versions, worlds can extend below y=0.
map: IntMap<ChunkPos, Weak<RwLock<Chunk>>>Implementations§
Trait Implementations§
Source§impl ChunkStorageTrait for WeakChunkStorage
impl ChunkStorageTrait for WeakChunkStorage
Source§fn 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.
Source§fn 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. Read more
fn chunks(&self) -> Box<[&ChunkPos]>
fn clone_box(&self) -> Box<dyn ChunkStorageTrait>
Source§fn get_block_state(&self, pos: BlockPos) -> Option<BlockState>
fn get_block_state(&self, pos: BlockPos) -> Option<BlockState>
Returns the [
BlockState] at the given position. Read moreSource§fn 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. Read morefn get_fluid_state(&self, pos: BlockPos) -> Option<FluidState>
fn get_biome(&self, pos: BlockPos) -> Option<Biome>
Source§impl Clone for WeakChunkStorage
impl Clone for WeakChunkStorage
Source§fn clone(&self) -> WeakChunkStorage
fn clone(&self) -> WeakChunkStorage
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for WeakChunkStorage
impl Debug for WeakChunkStorage
Auto Trait Implementations§
impl Freeze for WeakChunkStorage
impl !RefUnwindSafe for WeakChunkStorage
impl Send for WeakChunkStorage
impl Sync for WeakChunkStorage
impl Unpin for WeakChunkStorage
impl UnsafeUnpin for WeakChunkStorage
impl !UnwindSafe for WeakChunkStorage
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn 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>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which 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)
Converts
&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)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend 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
Creates Self using default().
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
Converts this type into the system output type.
§impl<T> TypeData for T
impl<T> TypeData for T
§fn clone_type_data(&self) -> Box<dyn TypeData>
fn clone_type_data(&self) -> Box<dyn TypeData>
Creates a type-erased clone of this value.