use azalea_inventory::ItemStack;
use hashbrown::HashMap;
#[derive(Debug, Clone)]
pub struct Inventory {
pub containers: HashMap<i32, InventoryContainer>,
}
#[derive(Debug, Clone)]
pub struct InventoryContainer {
pub carried_item: ItemStack,
pub items: Vec<InventoryItem>,
}
#[derive(Debug, Clone)]
pub struct InventoryItem {
pub name: String,
pub count: i32,
pub slot: u32,
}
impl Default for Inventory {
fn default() -> Self {
Self { containers: HashMap::new() }
}
}
impl Inventory {
pub fn get_container(&self, id: i32) -> Option<&InventoryContainer> {
self.containers.get(&id)
}
pub fn get_mut_container(&mut self, id: i32) -> Option<&mut InventoryContainer> {
self.containers.get_mut(&id)
}
pub fn add_container(&mut self, id: i32) {
self.containers.insert(
id,
InventoryContainer {
carried_item: ItemStack::Empty,
items: Vec::new(),
},
);
}
}