valence_inventory/
player_inventory.rs
1use std::ops::RangeInclusive;
2
3pub struct PlayerInventory;
4
5impl PlayerInventory {
6 pub const SLOT_OFFHAND: u16 = 45;
7 pub const SLOT_HEAD: u16 = 5;
8 pub const SLOT_CHEST: u16 = 6;
9 pub const SLOT_LEGS: u16 = 7;
10 pub const SLOT_FEET: u16 = 8;
11 pub const SLOTS_CRAFT_INPUT: RangeInclusive<u16> = 1..=4;
12 pub const SLOT_CRAFT_RESULT: u16 = 0;
13 pub const SLOTS_HOTBAR: RangeInclusive<u16> = 36..=44;
14 pub const SLOTS_MAIN: RangeInclusive<u16> = 9..=44;
15 pub const MAIN_SIZE: u16 = *Self::SLOTS_MAIN.end() - *Self::SLOTS_MAIN.start() + 1;
16
17 pub const fn hotbar_to_slot(hotbar: u8) -> u16 {
18 *Self::SLOTS_HOTBAR.start() + (hotbar as u16)
19 }
20
21 pub const fn slot_to_hotbar(slot: u16) -> u8 {
22 (slot - *Self::SLOTS_HOTBAR.start()) as u8
23 }
24}