pub struct BlockDropRegistry<I: ItemType> { /* private fields */ }Expand description
Registry that associates block content ids with author-defined item drops.
Implementations§
Source§impl<I: ItemType> BlockDropRegistry<I>
impl<I: ItemType> BlockDropRegistry<I>
Sourcepub fn register_drop(
&mut self,
block_id: impl Into<ContentId>,
drop: BlockDropDefinition<I>,
)
pub fn register_drop( &mut self, block_id: impl Into<ContentId>, drop: BlockDropDefinition<I>, )
Adds one drop definition for a block id.
Sourcepub fn get(&self, block_id: impl AsRef<str>) -> &[BlockDropDefinition<I>]
pub fn get(&self, block_id: impl AsRef<str>) -> &[BlockDropDefinition<I>]
Returns all drops registered for a block id.
Sourcepub fn contains_block_id(&self, block_id: impl AsRef<str>) -> bool
pub fn contains_block_id(&self, block_id: impl AsRef<str>) -> bool
Returns true when at least one drop exists for a block id.
Sourcepub fn len_for(&self, block_id: impl AsRef<str>) -> usize
pub fn len_for(&self, block_id: impl AsRef<str>) -> usize
Returns the number of drops registered for one block id.
Sourcepub fn iter(
&self,
) -> impl Iterator<Item = (&ContentId, &[BlockDropDefinition<I>])>
pub fn iter( &self, ) -> impl Iterator<Item = (&ContentId, &[BlockDropDefinition<I>])>
Iterates block ids and their drop lists in unspecified hash-map order.
Sourcepub fn snapshot(&self) -> Vec<BlockDropContentSnapshot>
pub fn snapshot(&self) -> Vec<BlockDropContentSnapshot>
Returns deterministic serializable snapshots of all registered drops.
Sourcepub fn get_for_voxel<V: VoxelType>(
&self,
voxel: V,
blocks: &BlockRegistry<V>,
) -> &[BlockDropDefinition<I>]
pub fn get_for_voxel<V: VoxelType>( &self, voxel: V, blocks: &BlockRegistry<V>, ) -> &[BlockDropDefinition<I>]
Returns all drops registered for a voxel value by first resolving it
through a BlockRegistry.
Sourcepub fn validate_blocks<V: VoxelType>(
&self,
blocks: &BlockRegistry<V>,
) -> Result<(), BlockDropRegistryError<I>>
pub fn validate_blocks<V: VoxelType>( &self, blocks: &BlockRegistry<V>, ) -> Result<(), BlockDropRegistryError<I>>
Validates that every drop references a registered block id.
Sourcepub fn validate_items(
&self,
items: &ItemRegistry<I>,
) -> Result<(), BlockDropRegistryError<I>>
pub fn validate_items( &self, items: &ItemRegistry<I>, ) -> Result<(), BlockDropRegistryError<I>>
Validates that every drop produces a registered item value.
Sourcepub fn to_drop_table<V: VoxelType>(
&self,
blocks: &BlockRegistry<V>,
) -> Result<DropTable<I>, BlockDropRegistryError<I>>
pub fn to_drop_table<V: VoxelType>( &self, blocks: &BlockRegistry<V>, ) -> Result<DropTable<I>, BlockDropRegistryError<I>>
Builds a runtime DropTable from author-defined block-drop content.
The registry is keyed by author-facing block ids. The runtime drop
pipeline is keyed by voxel bytes, so this method resolves each block id
through the provided BlockRegistry and writes the corresponding
voxel-byte entries into a fresh DropTable.
Sourcepub fn apply_to_drop_table<V: VoxelType>(
&self,
blocks: &BlockRegistry<V>,
table: &mut DropTable<I>,
) -> Result<(), BlockDropRegistryError<I>>
pub fn apply_to_drop_table<V: VoxelType>( &self, blocks: &BlockRegistry<V>, table: &mut DropTable<I>, ) -> Result<(), BlockDropRegistryError<I>>
Applies author-defined block drops to an existing runtime DropTable.
Entries for voxel bytes present in this registry are replaced, making the operation idempotent. Entries for unrelated voxel bytes are left untouched so game code can still mix hand-written runtime drops with content-defined drops.
Trait Implementations§
Source§impl<I: Clone + ItemType> Clone for BlockDropRegistry<I>
impl<I: Clone + ItemType> Clone for BlockDropRegistry<I>
Source§fn clone(&self) -> BlockDropRegistry<I>
fn clone(&self) -> BlockDropRegistry<I>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<I: ItemType> Default for BlockDropRegistry<I>
Available on crate feature items only.
impl<I: ItemType> Default for BlockDropRegistry<I>
items only.impl<I: ItemType> Resource for BlockDropRegistry<I>
Auto Trait Implementations§
impl<I> Freeze for BlockDropRegistry<I>
impl<I> RefUnwindSafe for BlockDropRegistry<I>
impl<I> Send for BlockDropRegistry<I>
impl<I> Sync for BlockDropRegistry<I>
impl<I> Unpin for BlockDropRegistry<I>
impl<I> UnsafeUnpin for BlockDropRegistry<I>
impl<I> UnwindSafe for BlockDropRegistry<I>
Blanket Implementations§
Source§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
Source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
T ShaderType for self. When used in AsBindGroup
derives, it is safe to assume that all images in self exist.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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ConditionalSend for Twhere
T: Send,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§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>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§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>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§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.Source§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<T> DowncastSend for T
impl<T> DowncastSend for T
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
Source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self using default().
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more