Struct valence_server::layer::chunk::ChunkLayer
source · pub struct ChunkLayer { /* private fields */ }
Expand description
A Component
containing the chunks and dimension
information of a
Minecraft world.
Implementations§
source§impl ChunkLayer
impl ChunkLayer
sourcepub fn new(
dimension_type_name: impl Into<Ident<String>>,
dimensions: &DimensionTypeRegistry,
biomes: &BiomeRegistry,
server: &Server
) -> Self
pub fn new( dimension_type_name: impl Into<Ident<String>>, dimensions: &DimensionTypeRegistry, biomes: &BiomeRegistry, server: &Server ) -> Self
Creates a new chunk layer.
sourcepub fn dimension_type_name(&self) -> Ident<&str>
pub fn dimension_type_name(&self) -> Ident<&str>
The name of the dimension this chunk layer is using.
sourcepub fn chunk(&self, pos: impl Into<ChunkPos>) -> Option<&LoadedChunk>
pub fn chunk(&self, pos: impl Into<ChunkPos>) -> Option<&LoadedChunk>
Get a reference to the chunk at the given position, if it is loaded.
sourcepub fn chunk_mut(
&mut self,
pos: impl Into<ChunkPos>
) -> Option<&mut LoadedChunk>
pub fn chunk_mut( &mut self, pos: impl Into<ChunkPos> ) -> Option<&mut LoadedChunk>
Get a mutable reference to the chunk at the given position, if it is loaded.
sourcepub fn insert_chunk(
&mut self,
pos: impl Into<ChunkPos>,
chunk: UnloadedChunk
) -> Option<UnloadedChunk>
pub fn insert_chunk( &mut self, pos: impl Into<ChunkPos>, chunk: UnloadedChunk ) -> Option<UnloadedChunk>
Insert a chunk into the instance at the given position. The preivous chunk data is returned.
sourcepub fn remove_chunk(
&mut self,
pos: impl Into<ChunkPos>
) -> Option<UnloadedChunk>
pub fn remove_chunk( &mut self, pos: impl Into<ChunkPos> ) -> Option<UnloadedChunk>
Unload the chunk at the given position, if it is loaded. Returns the chunk if it was loaded.
sourcepub fn clear_chunks(&mut self)
pub fn clear_chunks(&mut self)
Unload all chunks in this instance.
sourcepub fn retain_chunks<F>(&mut self, f: F)where
F: FnMut(ChunkPos, &mut LoadedChunk) -> bool,
pub fn retain_chunks<F>(&mut self, f: F)where F: FnMut(ChunkPos, &mut LoadedChunk) -> bool,
Retain only the chunks for which the given predicate returns true
.
sourcepub fn chunk_entry(&mut self, pos: impl Into<ChunkPos>) -> ChunkEntry<'_>
pub fn chunk_entry(&mut self, pos: impl Into<ChunkPos>) -> ChunkEntry<'_>
Get a ChunkEntry
for the given position.
sourcepub fn chunks(
&self
) -> impl Iterator<Item = (ChunkPos, &LoadedChunk)> + Clone + '_
pub fn chunks( &self ) -> impl Iterator<Item = (ChunkPos, &LoadedChunk)> + Clone + '_
Get an iterator over all loaded chunks in the instance. The order of the chunks is undefined.
sourcepub fn chunks_mut(
&mut self
) -> impl Iterator<Item = (ChunkPos, &mut LoadedChunk)> + '_
pub fn chunks_mut( &mut self ) -> impl Iterator<Item = (ChunkPos, &mut LoadedChunk)> + '_
Get an iterator over all loaded chunks in the instance, mutably. The order of the chunks is undefined.
sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Optimizes the memory usage of the instance.
pub fn block(&self, pos: impl Into<BlockPos>) -> Option<BlockRef<'_>>
pub fn set_block( &mut self, pos: impl Into<BlockPos>, block: impl IntoBlock ) -> Option<Block>
pub fn block_entity_mut( &mut self, pos: impl Into<BlockPos> ) -> Option<&mut Compound>
pub fn biome(&self, pos: impl Into<BlockPos>) -> Option<BiomeId>
pub fn set_biome( &mut self, pos: impl Into<BlockPos>, biome: BiomeId ) -> Option<BiomeId>
sourcepub fn play_particle(
&mut self,
particle: &Particle,
long_distance: bool,
position: impl Into<DVec3>,
offset: impl Into<Vec3>,
max_speed: f32,
count: i32
)
pub fn play_particle( &mut self, particle: &Particle, long_distance: bool, position: impl Into<DVec3>, offset: impl Into<Vec3>, max_speed: f32, count: i32 )
Puts a particle effect at the given position in the world. The particle effect is visible to all players in the instance with the appropriate chunk in view.
sourcepub fn play_sound(
&mut self,
sound: Sound,
category: SoundCategory,
position: impl Into<DVec3>,
volume: f32,
pitch: f32
)
pub fn play_sound( &mut self, sound: Sound, category: SoundCategory, position: impl Into<DVec3>, volume: f32, pitch: f32 )
Plays a sound effect at the given position in the world. The sound effect is audible to all players in the instance with the appropriate chunk in view.
Trait Implementations§
source§impl Component for ChunkLayerwhere
Self: Send + Sync + 'static,
impl Component for ChunkLayerwhere Self: Send + Sync + 'static,
§type Storage = TableStorage
type Storage = TableStorage
TableStorage
or SparseStorage
.source§impl Debug for ChunkLayer
impl Debug for ChunkLayer
source§impl Layer for ChunkLayer
impl Layer for ChunkLayer
§type ExceptWriter<'a> = ExceptWriter<'a>
type ExceptWriter<'a> = ExceptWriter<'a>
except_writer
.§type ViewWriter<'a> = ViewWriter<'a>
type ViewWriter<'a> = ViewWriter<'a>
view_writer
.§type ViewExceptWriter<'a> = ViewExceptWriter<'a>
type ViewExceptWriter<'a> = ViewExceptWriter<'a>
view_except_writer
.§type RadiusWriter<'a> = RadiusWriter<'a>
type RadiusWriter<'a> = RadiusWriter<'a>
radius_writer
.§type RadiusExceptWriter<'a> = RadiusExceptWriter<'a>
type RadiusExceptWriter<'a> = RadiusExceptWriter<'a>
radius_except_writer
.source§fn except_writer(&mut self, except: Entity) -> Self::ExceptWriter<'_>
fn except_writer(&mut self, except: Entity) -> Self::ExceptWriter<'_>
except
.source§fn view_writer(&mut self, pos: impl Into<ChunkPos>) -> Self::ViewWriter<'_>
fn view_writer(&mut self, pos: impl Into<ChunkPos>) -> Self::ViewWriter<'_>
pos
.source§fn view_except_writer(
&mut self,
pos: impl Into<ChunkPos>,
except: Entity
) -> Self::ViewExceptWriter<'_>
fn view_except_writer( &mut self, pos: impl Into<ChunkPos>, except: Entity ) -> Self::ViewExceptWriter<'_>
pos
and not identified by except
.source§fn radius_writer(
&mut self,
center: impl Into<BlockPos>,
radius: u32
) -> Self::RadiusWriter<'_>
fn radius_writer( &mut self, center: impl Into<BlockPos>, radius: u32 ) -> Self::RadiusWriter<'_>
radius
blocks of the block position pos
.source§fn radius_except_writer(
&mut self,
center: impl Into<BlockPos>,
radius: u32,
except: Entity
) -> Self::RadiusExceptWriter<'_>
fn radius_except_writer( &mut self, center: impl Into<BlockPos>, radius: u32, except: Entity ) -> Self::RadiusExceptWriter<'_>
radius
blocks of the block position pos
and not identified by except
.source§impl WritePacket for ChunkLayer
impl WritePacket for ChunkLayer
source§fn write_packet_fallible<P>(&mut self, packet: &P) -> Result<()>where
P: Packet + Encode,
fn write_packet_fallible<P>(&mut self, packet: &P) -> Result<()>where P: Packet + Encode,
source§fn write_packet_bytes(&mut self, bytes: &[u8])
fn write_packet_bytes(&mut self, bytes: &[u8])
Auto Trait Implementations§
impl !RefUnwindSafe for ChunkLayer
impl Send for ChunkLayer
impl Sync for ChunkLayer
impl Unpin for ChunkLayer
impl UnwindSafe for ChunkLayer
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<C> Bundle for Cwhere
C: Component,
impl<C> Bundle for Cwhere C: Component,
fn component_ids( components: &mut Components, storages: &mut Storages, ids: &mut impl FnMut(ComponentId) )
unsafe fn from_components<T, F>(ctx: &mut T, func: &mut F) -> Cwhere F: for<'a> FnMut(&'a mut T) -> OwningPtr<'a, Aligned>,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>
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, Global>) -> Rc<dyn Any, Global>
fn into_any_rc(self: Rc<T, Global>) -> Rc<dyn Any, Global>
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.source§impl<C> DynamicBundle for Cwhere
C: Component,
impl<C> DynamicBundle for Cwhere C: Component,
fn get_components( self, func: &mut impl FnMut(StorageType, OwningPtr<'_, Aligned>) )
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> SendMessage for Twhere
T: WritePacket,
impl<T> SendMessage for Twhere T: WritePacket,
source§fn send_chat_message<'a>(&mut self, msg: impl IntoText<'a>)
fn send_chat_message<'a>(&mut self, msg: impl IntoText<'a>)
source§fn send_action_bar_message<'a>(&mut self, msg: impl IntoText<'a>)
fn send_action_bar_message<'a>(&mut self, msg: impl IntoText<'a>)
source§impl<T> SetTitle for Twhere
T: WritePacket,
impl<T> SetTitle for Twhere T: WritePacket,
fn set_subtitle<'a>(&mut self, text: impl IntoText<'a>)
fn set_action_bar<'a>(&mut self, text: impl IntoText<'a>)
source§fn set_title_times(&mut self, fade_in: i32, stay: i32, fade_out: i32)
fn set_title_times(&mut self, fade_in: i32, stay: i32, fade_out: i32)
fade_in
: Ticks to spend fading in.stay
: Ticks to keep the title displayed.fade_out
: Ticks to spend fading out. Read more