pub struct ComponentEntry {
pub key: Identifier,
codecs: ComponentCodecs,
ignore_swap_animation: bool,
}Expand description
Metadata for a registered component type.
Contains the component’s key and all serialization functions needed to read/write the component for network and persistent storage.
Fields§
§key: IdentifierThe component’s identifier (e.g., “minecraft:damage”)
codecs: ComponentCodecs§ignore_swap_animation: boolImplementations§
Source§impl ComponentEntry
impl ComponentEntry
pub(super) fn implemented( key: Identifier, expected_type_key: DowncastTypeKey, network_reader: NetworkReader, network_writer: NetworkWriter, persistent_codecs: Option<(NbtReader, NbtWriter, fn(&ComponentData) -> Result<i32>, Option<fn(&ComponentData) -> Result<()>>)>, ignore_swap_animation: bool, ) -> Self
Sourcepub fn validates(&self, data: &ComponentData) -> bool
pub fn validates(&self, data: &ComponentData) -> bool
Validates that a ComponentData value matches the concrete type for this component.
Returns true if the data is valid for this component type, false otherwise.
This prevents plugins from setting wrong types on vanilla components.
Sourcepub fn read_network(&self, data: &mut Cursor<&[u8]>) -> Result<ComponentData>
pub fn read_network(&self, data: &mut Cursor<&[u8]>) -> Result<ComponentData>
Decodes this component’s network value.
Sourcepub fn write_network(
&self,
data: &ComponentData,
writer: &mut Vec<u8>,
) -> Result<()>
pub fn write_network( &self, data: &ComponentData, writer: &mut Vec<u8>, ) -> Result<()>
Encodes this component’s network value after validating its concrete type.
Sourcepub fn read_nbt(&self, tag: BorrowedNbtTag<'_, '_>) -> Option<ComponentData>
pub fn read_nbt(&self, tag: BorrowedNbtTag<'_, '_>) -> Option<ComponentData>
Decodes this component’s persistent NBT value.
Sourcepub fn write_nbt(&self, data: &ComponentData) -> Result<OwnedNbtTag>
pub fn write_nbt(&self, data: &ComponentData) -> Result<OwnedNbtTag>
Encodes this component’s persistent NBT value after validating its concrete type.
Sourcepub fn validate_persistent_encoding(
&self,
data: &ComponentData,
) -> Result<OwnedNbtTag>
pub fn validate_persistent_encoding( &self, data: &ComponentData, ) -> Result<OwnedNbtTag>
Checks that a value accepted by the stream codec is also accepted by the persistent codec.
Sourcepub fn compute_hash(&self, data: &ComponentData) -> Result<i32>
pub fn compute_hash(&self, data: &ComponentData) -> Result<i32>
Computes the vanilla HashOps value through this component’s persistent codec.
Sourcepub const fn is_persistent(&self) -> bool
pub const fn is_persistent(&self) -> bool
Returns whether vanilla defines this as a persistent component.
Sourcepub const fn ignore_swap_animation(&self) -> bool
pub const fn ignore_swap_animation(&self) -> bool
Returns whether changes to this component are ignored for held-item swap animation.
Sourcepub fn read_nbt_owned(&self, tag: &OwnedNbtTag) -> Option<ComponentData>
pub fn read_nbt_owned(&self, tag: &OwnedNbtTag) -> Option<ComponentData>
Decodes an owned NBT value with this component’s registered persistent codec.
Trait Implementations§
impl Eq for ComponentEntry
Source§impl PartialEq for ComponentEntry
impl PartialEq for ComponentEntry
Auto Trait Implementations§
impl Freeze for ComponentEntry
impl RefUnwindSafe for ComponentEntry
impl Send for ComponentEntry
impl Sync for ComponentEntry
impl Unpin for ComponentEntry
impl UnsafeUnpin for ComponentEntry
impl UnwindSafe for ComponentEntry
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
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§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<>>