classicube_sys/
inventory.rs1use crate::{
2 bindings::{BlockID, Inventory},
3 std_types::c_int,
4};
5
6#[must_use]
12pub fn Inventory_Get(idx: c_int) -> BlockID {
13 let i = usize::try_from(unsafe { Inventory.Offset } + idx).expect("hotbar index out of range");
14 unsafe { Inventory.Table[i] }
15}
16
17pub fn Inventory_Set(idx: c_int, block: BlockID) {
23 let i = usize::try_from(unsafe { Inventory.Offset } + idx).expect("hotbar index out of range");
24 unsafe {
25 Inventory.Table[i] = block;
26 }
27}
28
29#[must_use]
31pub fn Inventory_SelectedBlock() -> BlockID {
32 unsafe { Inventory_Get(Inventory.SelectedIndex) }
33}