Skip to main content

steel_core/behavior/items/
air.rs

1use std::borrow::Cow;
2
3use steel_macros::item_behavior;
4use steel_registry::{data_components::vanilla_components::ITEM_NAME, item_stack::ItemStack};
5use text_components::TextComponent;
6
7use crate::behavior::ItemBehavior;
8
9/// Air behavior using the item type's prototype name like Vanilla `AirItem`.
10#[item_behavior]
11pub struct AirItem;
12
13impl ItemBehavior for AirItem {
14    fn get_name<'a>(&self, stack: &'a ItemStack) -> Cow<'a, TextComponent> {
15        stack
16            .item()
17            .components
18            .get_ref(ITEM_NAME)
19            .map_or_else(|| Cow::Owned(TextComponent::new()), Cow::Borrowed)
20    }
21}