azalea_inventory/item/
mod.rs

1use crate::{components::MaxStackSize, default_components::get_default_component};
2
3pub mod consume_effect;
4
5pub trait MaxStackSizeExt {
6    /// Get the maximum stack size for this item.
7    ///
8    /// This is a signed integer to be consistent with the `count` field of
9    /// [`ItemStackData`].
10    ///
11    /// [`ItemStackData`]: crate::ItemStackData
12    fn max_stack_size(&self) -> i32;
13
14    /// Whether this item can be stacked with other items.
15    ///
16    /// This is equivalent to `self.max_stack_size() > 1`.
17    fn stackable(&self) -> bool {
18        self.max_stack_size() > 1
19    }
20}
21
22impl MaxStackSizeExt for azalea_registry::Item {
23    fn max_stack_size(&self) -> i32 {
24        get_default_component::<MaxStackSize>(*self).map_or(64, |s| s.count)
25    }
26}