pub struct ItemData<T> { /* private fields */ }Expand description
A value kept in the data of the stack a player holds, at its key (the
mod’s own: <mod>:<key>); its default where the stack has none yet.
ⓘ
static CHARGES: ItemData<u32> = ItemData::new("charges");
CHARGES.update(&use_item.player, use_item.off_hand, |n| *n = n.saturating_sub(1));Implementations§
Source§impl<T: Schema + Default> ItemData<T>
impl<T: Schema + Default> ItemData<T>
pub const fn new(key: &'static str) -> Self
Sourcepub fn get(&self, player: &str, off_hand: bool) -> T
pub fn get(&self, player: &str, off_hand: bool) -> T
The value on the stack player holds (off_hand: in its other
hand); its default when the stack has none (or there’s no stack).
Sourcepub fn held_here(&self, off_hand: bool) -> T
pub fn held_here(&self, off_hand: bool) -> T
The value on the stack this client’s player holds (off_hand: in
its other hand), as the server last sent the stack — the game sends
stacks, so every ItemData is synced; its default when the stack has
none (or there’s no stack).
Auto Trait Implementations§
impl<T> Freeze for ItemData<T>
impl<T> RefUnwindSafe for ItemData<T>
impl<T> Send for ItemData<T>
impl<T> Sync for ItemData<T>
impl<T> Unpin for ItemData<T>
impl<T> UnsafeUnpin for ItemData<T>
impl<T> UnwindSafe for ItemData<T>
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