mirror of
https://github.com/Pumpkin-MC/Pumpkin.git
synced 2026-08-31 08:22:33 +00:00
21 lines
517 B
Rust
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()
|
|
}
|
|
}
|