steel_core/inventory/container/
simple.rs1use steel_registry::item_stack::ItemStack;
2use steel_utils::{DowncastType, DowncastTypeKey};
3
4use crate::inventory::container::Container;
5
6pub struct SimpleContainer {
8 items: Vec<ItemStack>,
9}
10
11unsafe impl DowncastType for SimpleContainer {
13 const TYPE_KEY: DowncastTypeKey = DowncastTypeKey::new("steel:container/simple");
14}
15
16impl SimpleContainer {
17 #[must_use]
19 pub fn new(size: usize) -> Self {
20 Self {
21 items: vec![ItemStack::empty(); size],
22 }
23 }
24
25 #[must_use]
27 pub const fn from_items(items: Vec<ItemStack>) -> Self {
28 Self { items }
29 }
30}
31
32impl Container for SimpleContainer {
33 fn items(&self) -> &[ItemStack] {
34 &self.items
35 }
36
37 fn items_mut(&mut self) -> &mut [ItemStack] {
38 &mut self.items
39 }
40
41 fn set_changed(&mut self) {}
42}