pub struct ItemStackTemplate {
item: ItemRef,
count: i32,
components: DataComponentPatch,
components_hash: Option<i32>,
}Expand description
A persistable, non-empty item identity, count, and component patch.
Fields§
§item: ItemRef§count: i32§components: DataComponentPatch§components_hash: Option<i32>Implementations§
Source§impl ItemStackTemplate
impl ItemStackTemplate
pub const MIN_COUNT: i32 = 1
pub const MAX_COUNT: i32 = 99
Sourcepub fn new(item: ItemRef) -> Self
pub fn new(item: ItemRef) -> Self
Creates the common count-one template with no component changes.
Sourcepub fn with_count(item: ItemRef, count: i32) -> Self
pub fn with_count(item: ItemRef, count: i32) -> Self
Creates a template with a validated persistent count and no component changes.
Sourcepub fn try_with_count_and_patch(
item: ItemRef,
count: i32,
components: DataComponentPatch,
) -> Result<Self>
pub fn try_with_count_and_patch( item: ItemRef, count: i32, components: DataComponentPatch, ) -> Result<Self>
Creates a template after validating its complete persistent codec shape.
Sourcepub(crate) fn from_extracted(
item: ItemRef,
count: i32,
components: DataComponentPatch,
components_hash: i32,
) -> Self
pub(crate) fn from_extracted( item: ItemRef, count: i32, components: DataComponentPatch, components_hash: i32, ) -> Self
Constructs a template from build-time validated Vanilla extractor data.
This avoids persistent codec validation during registry bootstrap because
registry-aware component codecs cannot consult REGISTRY until it has
been completely built and published.
Sourcepub fn from_stack(stack: &ItemStack) -> Result<Self>
pub fn from_stack(stack: &ItemStack) -> Result<Self>
Copies a non-empty stack into its immutable template representation.
pub(crate) fn validate_persistent_encoding(&self) -> Result<()>
pub const fn item(&self) -> ItemRef
pub const fn count(&self) -> i32
pub const fn components(&self) -> &DataComponentPatch
pub fn create(&self) -> ItemStack
Sourcepub fn apply(
&self,
count: i32,
additional_components: &DataComponentPatch,
) -> ItemStack
pub fn apply( &self, count: i32, additional_components: &DataComponentPatch, ) -> ItemStack
Creates this template over an existing component patch, matching
Vanilla’s ItemStackTemplate.apply precedence rules.
Sourcepub fn to_hover_event(&self) -> Result<HoverEvent>
pub fn to_hover_event(&self) -> Result<HoverEvent>
Creates the Vanilla hover event for this item template.
pub(crate) fn to_nbt_tag_ref(&self) -> NbtTag
pub(crate) fn from_nbt_identifier(value: &str) -> Option<Self>
pub(crate) fn from_nbt_compound(compound: NbtCompound<'_, '_>) -> Option<Self>
fn from_stream( item: ItemRef, count: i32, components: DataComponentPatch, ) -> Result<Self>
Sourcepub fn get_effective_value_raw(
&self,
key: &Identifier,
) -> Option<&ComponentData>
pub fn get_effective_value_raw( &self, key: &Identifier, ) -> Option<&ComponentData>
Gets the effective raw component value from the patch or item prototype.
Sourcepub fn get<T: Component + DowncastType>(
&self,
component: DataComponentType<T>,
) -> Option<&T>
pub fn get<T: Component + DowncastType>( &self, component: DataComponentType<T>, ) -> Option<&T>
Gets an effective typed component value from the patch or item prototype.
pub(crate) fn max_stack_size(&self) -> i32
Trait Implementations§
Source§impl Clone for ItemStackTemplate
impl Clone for ItemStackTemplate
Source§fn clone(&self) -> ItemStackTemplate
fn clone(&self) -> ItemStackTemplate
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ItemStackTemplate
impl Debug for ItemStackTemplate
Source§impl FromNbtTag for ItemStackTemplate
impl FromNbtTag for ItemStackTemplate
fn from_nbt_tag(tag: NbtTag<'_, '_>) -> Option<Self>
fn from_optional_nbt_tag( tag: Option<NbtTag<'_, '_>>, ) -> Result<Option<Self>, DeserializeError>
Source§impl HashComponent for ItemStackTemplate
impl HashComponent for ItemStackTemplate
Source§fn hash_component(&self, hasher: &mut ComponentHasher)
fn hash_component(&self, hasher: &mut ComponentHasher)
Source§fn compute_hash(&self) -> i32
fn compute_hash(&self) -> i32
Source§impl PartialEq for ItemStackTemplate
impl PartialEq for ItemStackTemplate
Source§impl ReadFrom for ItemStackTemplate
impl ReadFrom for ItemStackTemplate
impl StructuralPartialEq for ItemStackTemplate
Source§impl ToNbtTag for ItemStackTemplate
impl ToNbtTag for ItemStackTemplate
fn to_nbt_tag(self) -> NbtTag
fn to_optional_nbt_tag(self) -> Option<NbtTag>
Auto Trait Implementations§
impl !RefUnwindSafe for ItemStackTemplate
impl !UnwindSafe for ItemStackTemplate
impl Freeze for ItemStackTemplate
impl Send for ItemStackTemplate
impl Sync for ItemStackTemplate
impl Unpin for ItemStackTemplate
impl UnsafeUnpin for ItemStackTemplate
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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> ⓘ
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 moreArc<SyncMutex<>>