steel_core/inventory/slots/
enchantment_slots.rs1use steel_registry::item_stack::ItemStack;
4use steel_utils::{DowncastType, DowncastTypeKey};
5
6use crate::inventory::lock::{ContainerLockGuard, ContainerRef};
7use crate::inventory::slots::{NormalSlot, Slot, SlotStorage};
8
9pub struct EnchantItemSlot {
11 base: NormalSlot,
12}
13
14unsafe impl DowncastType for EnchantItemSlot {
16 const TYPE_KEY: DowncastTypeKey = DowncastTypeKey::new("steel:slot/enchant_item");
17}
18
19impl EnchantItemSlot {
20 pub fn new(container: impl Into<ContainerRef>, index: usize) -> Self {
22 Self {
23 base: NormalSlot::new(container, index),
24 }
25 }
26}
27
28impl Slot for EnchantItemSlot {
29 fn storage(&self) -> &SlotStorage {
30 self.base.storage()
31 }
32
33 fn get_item<'a>(&self, guard: &'a ContainerLockGuard) -> &'a ItemStack {
34 self.base.get_item(guard)
35 }
36
37 fn get_item_mut<'a>(&self, guard: &'a mut ContainerLockGuard) -> &'a mut ItemStack {
38 self.base.get_item_mut(guard)
39 }
40
41 fn set_item(&self, guard: &mut ContainerLockGuard, stack: ItemStack) {
42 self.base.set_item(guard, stack);
43 }
44
45 fn get_max_stack_size(&self, _guard: &ContainerLockGuard) -> i32 {
46 1
47 }
48
49 fn set_changed(&self, guard: &mut ContainerLockGuard) {
50 self.base.set_changed(guard);
51 }
52
53 fn get_container_slot(&self) -> usize {
54 self.base.get_container_slot()
55 }
56}