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<N: Into<Ident<String>>>(
dimension_type_name: N,
dimensions: &DimensionTypeRegistry,
biomes: &BiomeRegistry,
server: &Server,
) -> Self
pub fn new<N: Into<Ident<String>>>( dimension_type_name: N, 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<P: Into<ChunkPos>>(&self, pos: P) -> Option<&LoadedChunk>
pub fn chunk<P: Into<ChunkPos>>(&self, pos: P) -> Option<&LoadedChunk>
Get a reference to the chunk at the given position, if it is loaded.
sourcepub fn chunk_mut<P: Into<ChunkPos>>(
&mut self,
pos: P,
) -> Option<&mut LoadedChunk>
pub fn chunk_mut<P: Into<ChunkPos>>( &mut self, pos: P, ) -> Option<&mut LoadedChunk>
Get a mutable reference to the chunk at the given position, if it is loaded.
sourcepub fn insert_chunk<P: Into<ChunkPos>>(
&mut self,
pos: P,
chunk: UnloadedChunk,
) -> Option<UnloadedChunk>
pub fn insert_chunk<P: Into<ChunkPos>>( &mut self, pos: P, chunk: UnloadedChunk, ) -> Option<UnloadedChunk>
Insert a chunk into the instance at the given position. The previous chunk data is returned.
sourcepub fn remove_chunk<P: Into<ChunkPos>>(
&mut self,
pos: P,
) -> Option<UnloadedChunk>
pub fn remove_chunk<P: Into<ChunkPos>>( &mut self, pos: P, ) -> 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)
pub fn retain_chunks<F>(&mut self, f: F)
Retain only the chunks for which the given predicate returns true
.
sourcepub fn chunk_entry<P: Into<ChunkPos>>(&mut self, pos: P) -> ChunkEntry<'_>
pub fn chunk_entry<P: Into<ChunkPos>>(&mut self, pos: P) -> 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<P: Into<BlockPos>>(&self, pos: P) -> Option<BlockRef<'_>>
pub fn set_block<P, B>(&mut self, pos: P, block: B) -> Option<Block>
pub fn block_entity_mut<P: Into<BlockPos>>( &mut self, pos: P, ) -> Option<&mut Compound>
pub fn biome<P: Into<BiomePos>>(&self, pos: P) -> Option<BiomeId>
pub fn set_biome<P: Into<BiomePos>>( &mut self, pos: P, biome: BiomeId, ) -> Option<BiomeId>
sourcepub fn play_particle<P, O>(
&mut self,
particle: &Particle,
long_distance: bool,
position: P,
offset: O,
max_speed: f32,
count: i32,
)
pub fn play_particle<P, O>( &mut self, particle: &Particle, long_distance: bool, position: P, offset: O, 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.
Trait Implementations§
source§impl Component for ChunkLayer
impl Component for ChunkLayer
source§const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
§fn register_component_hooks(_hooks: &mut ComponentHooks)
fn register_component_hooks(_hooks: &mut ComponentHooks)
ComponentHooks
].source§impl Debug for ChunkLayer
impl Debug for ChunkLayer
source§impl Layer for ChunkLayer
impl Layer for ChunkLayer
source§type ExceptWriter<'a> = ExceptWriter<'a>
type ExceptWriter<'a> = ExceptWriter<'a>
except_writer
.source§type ViewWriter<'a> = ViewWriter<'a>
type ViewWriter<'a> = ViewWriter<'a>
view_writer
.source§type ViewExceptWriter<'a> = ViewExceptWriter<'a>
type ViewExceptWriter<'a> = ViewExceptWriter<'a>
view_except_writer
.source§type RadiusWriter<'a> = RadiusWriter<'a>
type RadiusWriter<'a> = RadiusWriter<'a>
radius_writer
.source§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])
§fn write_packet<P>(&mut self, packet: &P)where
P: Packet + Encode,
fn write_packet<P>(&mut self, packet: &P)where
P: Packet + Encode,
Auto Trait Implementations§
impl Freeze for ChunkLayer
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
§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) -> C
§fn get_component_ids(
components: &Components,
ids: &mut impl FnMut(Option<ComponentId>),
)
fn get_component_ids( components: &Components, ids: &mut impl FnMut(Option<ComponentId>), )
Bundle
]’s component ids. This will be None
if the component has not been registered.§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<C> DynamicBundle for Cwhere
C: Component,
impl<C> DynamicBundle for Cwhere
C: Component,
fn get_components(self, func: &mut impl FnMut(StorageType, OwningPtr<'_>))
§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>
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