pub struct ItemRegistry {
items_by_id: Vec<ItemRef>,
items_by_key: FxHashMap<Identifier, usize>,
items_by_block: FxHashMap<Identifier, usize>,
block_items_by_id: Vec<bool>,
tags: RegistryTags,
allows_registering: bool,
}Fields§
§items_by_id: Vec<ItemRef>§items_by_key: FxHashMap<Identifier, usize>§items_by_block: FxHashMap<Identifier, usize>§block_items_by_id: Vec<bool>§allows_registering: boolImplementations§
Source§impl ItemRegistry
impl ItemRegistry
pub fn new() -> Self
pub fn register(&mut self, item: ItemRef) -> usize
Sourcepub fn register_block_item(&mut self, block: BlockRef, item: ItemRef)
pub fn register_block_item(&mut self, block: BlockRef, item: ItemRef)
Registers the vanilla BlockItem association used by Block.asItem().
Sourcepub fn is_block_item(&self, item: ItemRef) -> bool
pub fn is_block_item(&self, item: ItemRef) -> bool
Returns whether this item is Vanilla’s BlockItem or one of its subclasses.
BlockItem construction registers its block-to-item association, so the
extracted association is also the complete class-hierarchy capability.
Sourcepub fn by_block(&self, block: BlockRef) -> ItemRef
pub fn by_block(&self, block: BlockRef) -> ItemRef
Returns the item associated with this block, or air when it has no block item.
Vanilla equivalent: Item.byBlock(Block) / Block.asItem().
pub fn iter(&self) -> impl Iterator<Item = (usize, ItemRef)> + '_
Trait Implementations§
Source§impl Default for ItemRegistry
impl Default for ItemRegistry
Source§impl DowncastType for ItemRegistry
impl DowncastType for ItemRegistry
Source§const TYPE_KEY: DowncastTypeKey
const TYPE_KEY: DowncastTypeKey
The process-wide key for this concrete type.
Source§impl RegistryExt for ItemRegistry
impl RegistryExt for ItemRegistry
type Entry = Item
fn freeze(&mut self)
fn by_id(&self, id: usize) -> Option<&'static Item>
fn by_key(&self, key: &Identifier) -> Option<&'static Item>
fn id_from_key(&self, key: &Identifier) -> Option<usize>
fn len(&self) -> usize
fn is_empty(&self) -> bool
Source§impl TaggedRegistryExt for ItemRegistry
impl TaggedRegistryExt for ItemRegistry
fn register_tag(&mut self, tag: Identifier, keys: &[&'static str])
fn modify_tag( &mut self, tag: &Identifier, f: impl FnOnce(Vec<Identifier>) -> Vec<Identifier>, )
fn is_in_tag(&self, entry: &Self::Entry, tag: &Identifier) -> bool
fn get_tag(&self, tag: &Identifier) -> Option<Vec<&'static Self::Entry>>
fn iter_tag( &self, tag: &Identifier, ) -> impl Iterator<Item = &'static Self::Entry> + '_
fn tag_keys(&self) -> impl Iterator<Item = &Identifier> + '_
Auto Trait Implementations§
impl !RefUnwindSafe for ItemRegistry
impl !UnwindSafe for ItemRegistry
impl Freeze for ItemRegistry
impl Send for ItemRegistry
impl Sync for ItemRegistry
impl Unpin for ItemRegistry
impl UnsafeUnpin for ItemRegistry
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
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: ErasedType + ?Sized,
impl<T> Downcast for Twhere
T: ErasedType + ?Sized,
Source§fn is<T>(&self) -> boolwhere
T: DowncastType,
fn is<T>(&self) -> boolwhere
T: DowncastType,
Returns whether the erased value has concrete type
T.Source§fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastType,
fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastType,
Returns the erased value as
T when its key matches.Source§fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: DowncastType,
fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: DowncastType,
Returns the erased value as mutable
T when its key matches.Source§impl<T> ErasedType for Twhere
T: DowncastType,
impl<T> ErasedType for Twhere
T: DowncastType,
fn downcast_type_key(&self) -> DowncastTypeKey
fn downcast_data(&self) -> *const ()
fn downcast_data_mut(&mut self) -> *mut ()
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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> ⓘ
Converts
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> ⓘ
Converts
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 moreWraps this value in an
Arc<SyncMutex<>>