Files
Pumpkin/pumpkin-world/src/inventory/mod.rs

21 lines
517 B
Rust

use std::sync::Arc;
use tokio::sync::Mutex;
use pumpkin_data::item_stack::ItemStack;
#[expect(clippy::module_inception)]
mod inventory;
pub use inventory::*;
// These are some utility functions found in Inventories.java
pub async fn split_stack(stacks: &[Arc<Mutex<ItemStack>>], slot: usize, amount: u8) -> ItemStack {
let mut stack = stacks[slot].lock().await;
if slot < stacks.len() && !stack.is_empty() && amount > 0 {
stack.split(amount)
} else {
ItemStack::EMPTY.clone()
}
}