pub struct Item {
pub key: Identifier,
pub components: DataComponentMap,
pub craft_remainder: Option<Identifier>,
pub id: OnceLock<usize>,
}Expand description
A Minecraft item type.
Fields§
§key: Identifier§components: DataComponentMap§craft_remainder: Option<Identifier>The item key returned when this item is used in crafting (e.g., “bucket” from milk_bucket). Stored as an Identifier to avoid circular reference issues during initialization.
id: OnceLock<usize>Cached registry ID, set during registration for O(1) lookup on hot paths.
Implementations§
Source§impl Item
impl Item
pub fn from_block(block: BlockRef) -> Self
pub fn from_block_custom_name(_block: BlockRef, name: &'static str) -> Self
Sourcepub fn builder_set<T: Component>(
self,
component: DataComponentType<T>,
value: Option<T>,
) -> Self
pub fn builder_set<T: Component>( self, component: DataComponentType<T>, value: Option<T>, ) -> Self
Builder method to set a component on this item. Used during static initialization.
Sourcepub fn get_crafting_remainder(&self) -> ItemStack
pub fn get_crafting_remainder(&self) -> ItemStack
Returns the item stack that remains after this item is used in crafting. For example, milk_bucket returns an empty bucket.
Sourcepub fn has_tag(&'static self, tag: &Identifier) -> bool
pub fn has_tag(&'static self, tag: &Identifier) -> bool
Returns true if this item is tagged with the given tag.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Item
impl RefUnwindSafe for Item
impl Send for Item
impl Sync for Item
impl Unpin for Item
impl UnsafeUnpin for Item
impl UnwindSafe for Item
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