pub struct ChunkLayer { /* private fields */ }
Expand description

A Component containing the chunks and dimension information of a Minecraft world.

Implementations§

source§

impl ChunkLayer

source

pub fn new( dimension_type_name: impl Into<Ident<String>>, dimensions: &DimensionTypeRegistry, biomes: &BiomeRegistry, server: &Server ) -> Self

Creates a new chunk layer.

source

pub fn dimension_type_name(&self) -> Ident<&str>

The name of the dimension this chunk layer is using.

source

pub fn height(&self) -> u32

The height of this instance’s dimension.

source

pub fn min_y(&self) -> i32

The min_y of this instance’s dimension.

source

pub fn chunk(&self, pos: impl Into<ChunkPos>) -> Option<&LoadedChunk>

Get a reference to the chunk at the given position, if it is loaded.

source

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.

source

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.

source

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.

source

pub fn clear_chunks(&mut self)

Unload all chunks in this instance.

source

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.

source

pub fn chunk_entry(&mut self, pos: impl Into<ChunkPos>) -> ChunkEntry<'_>

Get a ChunkEntry for the given position.

source

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.

source

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.

source

pub fn shrink_to_fit(&mut self)

Optimizes the memory usage of the instance.

source

pub fn block(&self, pos: impl Into<BlockPos>) -> Option<BlockRef<'_>>

source

pub fn set_block( &mut self, pos: impl Into<BlockPos>, block: impl IntoBlock ) -> Option<Block>

source

pub fn block_entity_mut( &mut self, pos: impl Into<BlockPos> ) -> Option<&mut Compound>

source

pub fn biome(&self, pos: impl Into<BlockPos>) -> Option<BiomeId>

source

pub fn set_biome( &mut self, pos: impl Into<BlockPos>, biome: BiomeId ) -> Option<BiomeId>

source

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.

source

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,

§

type Storage = TableStorage

A marker type indicating the storage type used for this component. This must be either TableStorage or SparseStorage.
source§

impl Debug for ChunkLayer

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Layer for ChunkLayer

§

type ExceptWriter<'a> = ExceptWriter<'a>

Packet writer returned by except_writer.
§

type ViewWriter<'a> = ViewWriter<'a>

Packet writer returned by view_writer.
§

type ViewExceptWriter<'a> = ViewExceptWriter<'a>

Packet writer returned by view_except_writer.
§

type RadiusWriter<'a> = RadiusWriter<'a>

Packet writer returned by radius_writer.
§

type RadiusExceptWriter<'a> = RadiusExceptWriter<'a>

Packet writer returned by radius_except_writer.
source§

fn except_writer(&mut self, except: Entity) -> Self::ExceptWriter<'_>

Returns a packet writer which sends packets to all viewers not identified by except.
source§

fn view_writer(&mut self, pos: impl Into<ChunkPos>) -> Self::ViewWriter<'_>

Returns a packet writer which sends packets to viewers in view of the chunk position pos.
source§

fn view_except_writer( &mut self, pos: impl Into<ChunkPos>, except: Entity ) -> Self::ViewExceptWriter<'_>

Returns a packet writer which sends packets to viewers in view of the chunk position pos and not identified by except.
source§

fn radius_writer( &mut self, center: impl Into<BlockPos>, radius: u32 ) -> Self::RadiusWriter<'_>

Returns a packet writer which sends packets to viewers within radius blocks of the block position pos.
source§

fn radius_except_writer( &mut self, center: impl Into<BlockPos>, radius: u32, except: Entity ) -> Self::RadiusExceptWriter<'_>

Returns a packet writer which sends packets to viewers within radius blocks of the block position pos and not identified by except.
source§

impl WritePacket for ChunkLayer

source§

fn write_packet_fallible<P>(&mut self, packet: &P) -> Result<()>where P: Packet + Encode,

Writes a packet to this object. The result of encoding the packet is returned.
source§

fn write_packet_bytes(&mut self, bytes: &[u8])

Copies raw packet data directly into this object. Don’t use this unless you know what you’re doing.
source§

fn write_packet<P>(&mut self, packet: &P)where P: Packet + Encode,

Writes a packet to this object. Encoding errors are typically logged and discarded.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<C> Bundle for Cwhere C: Component,

source§

fn component_ids( components: &mut Components, storages: &mut Storages, ids: &mut impl FnMut(ComponentId) )

source§

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,

§

fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>

Convert 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>

Convert 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)

Convert &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)

Convert &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 Twhere T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T, Global>) -> Arc<dyn Any + Sync + Send, Global>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<C> DynamicBundle for Cwhere C: Component,

source§

fn get_components( self, func: &mut impl FnMut(StorageType, OwningPtr<'_, Aligned>) )

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> SendMessage for Twhere T: WritePacket,

source§

fn send_chat_message<'a>(&mut self, msg: impl IntoText<'a>)

Sends a system message visible in the chat.
source§

fn send_action_bar_message<'a>(&mut self, msg: impl IntoText<'a>)

Displays a message in the player’s action bar (text above the hotbar).
source§

impl<T> SetTitle for Twhere T: WritePacket,

source§

fn set_title<'a>(&mut self, text: impl IntoText<'a>)

Displays a title to a client. Read more
source§

fn set_subtitle<'a>(&mut self, text: impl IntoText<'a>)

source§

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)

fade_in: Ticks to spend fading in.stay: Ticks to keep the title displayed.fade_out: Ticks to spend fading out. Read more
source§

fn clear_title(&mut self)

source§

fn reset_title(&mut self)

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more