Struct valence::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>(
dimension_type_name: N,
dimensions: &DimensionTypeRegistry,
biomes: &BiomeRegistry,
server: &Server,
) -> ChunkLayer
pub fn new<N>( dimension_type_name: N, dimensions: &DimensionTypeRegistry, biomes: &BiomeRegistry, server: &Server, ) -> ChunkLayer
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>(&self, pos: P) -> Option<&LoadedChunk>
pub fn chunk<P>(&self, pos: P) -> Option<&LoadedChunk>
Get a reference to the chunk at the given position, if it is loaded.
sourcepub fn chunk_mut<P>(&mut self, pos: P) -> Option<&mut LoadedChunk>
pub fn chunk_mut<P>(&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>(
&mut self,
pos: P,
chunk: UnloadedChunk,
) -> Option<UnloadedChunk>
pub fn insert_chunk<P>( &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>(&mut self, pos: P) -> Option<UnloadedChunk>
pub fn remove_chunk<P>(&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>(&mut self, pos: P) -> ChunkEntry<'_>
pub fn chunk_entry<P>(&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>(&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>(&mut self, pos: P) -> Option<&mut Compound>
pub fn biome<P>(&self, pos: P) -> Option<BiomeId>
pub fn set_biome<P>(&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.
sourcepub fn play_sound<P>(
&mut self,
sound: Sound,
category: SoundCategory,
position: P,
volume: f32,
pitch: f32,
)
pub fn play_sound<P>( &mut self, sound: Sound, category: SoundCategory, position: P, 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 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,
) -> <ChunkLayer as Layer>::ExceptWriter<'_>
fn except_writer( &mut self, except: Entity, ) -> <ChunkLayer as Layer>::ExceptWriter<'_>
except
.source§fn view_writer(
&mut self,
pos: impl Into<ChunkPos>,
) -> <ChunkLayer as Layer>::ViewWriter<'_>
fn view_writer( &mut self, pos: impl Into<ChunkPos>, ) -> <ChunkLayer as Layer>::ViewWriter<'_>
pos
.source§fn view_except_writer(
&mut self,
pos: impl Into<ChunkPos>,
except: Entity,
) -> <ChunkLayer as Layer>::ViewExceptWriter<'_>
fn view_except_writer( &mut self, pos: impl Into<ChunkPos>, except: Entity, ) -> <ChunkLayer as Layer>::ViewExceptWriter<'_>
pos
and not identified by except
.source§fn radius_writer(
&mut self,
center: impl Into<BlockPos>,
radius: u32,
) -> <ChunkLayer as Layer>::RadiusWriter<'_>
fn radius_writer( &mut self, center: impl Into<BlockPos>, radius: u32, ) -> <ChunkLayer as Layer>::RadiusWriter<'_>
radius
blocks of the block position pos
.source§fn radius_except_writer(
&mut self,
center: impl Into<BlockPos>,
radius: u32,
except: Entity,
) -> <ChunkLayer as Layer>::RadiusExceptWriter<'_>
fn radius_except_writer( &mut self, center: impl Into<BlockPos>, radius: u32, except: Entity, ) -> <ChunkLayer as Layer>::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<(), Error>
fn write_packet_fallible<P>(&mut self, packet: &P) -> Result<(), Error>
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)
fn write_packet<P>(&mut self, packet: &P)
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>), )
§impl<T> Conv for T
impl<T> Conv for 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<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> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§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> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.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> SetBrand for Twhere
T: WritePacket,
impl<T> SetBrand for Twhere
T: WritePacket,
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 morefn clear_title(&mut self)
fn reset_title(&mut self)
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.