Skip to main content

steel_core/behavior/items/
tipped_arrow.rs

1use std::borrow::Cow;
2
3use steel_macros::item_behavior;
4use steel_registry::data_components::PotionContents;
5use steel_registry::item_stack::ItemStack;
6use steel_registry::items::ItemRef;
7use steel_registry::vanilla_potions;
8use text_components::TextComponent;
9
10use crate::behavior::ItemBehavior;
11
12use super::dynamic_name::potion_name;
13
14/// Tipped-arrow behavior providing Vanilla's potion-content-dependent name and
15/// poison default instance.
16// TODO: Implement inherited ArrowItem projectile and dispenser behavior once
17// ProjectileItem dispatch exists.
18#[item_behavior]
19pub struct TippedArrowItem;
20
21impl ItemBehavior for TippedArrowItem {
22    fn get_name<'a>(&self, stack: &'a ItemStack) -> Cow<'a, TextComponent> {
23        potion_name(stack)
24    }
25
26    fn get_default_instance(&self, item: ItemRef) -> ItemStack {
27        PotionContents::create_item_stack(item, &vanilla_potions::POISON)
28    }
29}