Skip to content

Commit

Permalink
fix: try_add_item (#540)
Browse files Browse the repository at this point in the history
Fixes #537
  • Loading branch information
CuzImClicks authored Oct 30, 2024
1 parent bf7663b commit 7490b44
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions crates/hyperion-inventory/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,9 @@ impl PlayerInventory {
pub fn try_add_item(&mut self, mut item: ItemStack) -> AddItemResult {
let mut result = AddItemResult { remaining: None };

// Try to add to hand slots (36-45) first, then the rest of the inventory (0-35)
// Try to add to hot bar (36-45) first, then the rest of the inventory (9-35)
// try to stack first
for slot in (36..=45).chain(0..36) {
for slot in (36..=44).chain(9..36) {
let Ok(add_slot) = self.try_add_to_slot(slot, &mut item, false) else {
unreachable!("try_add_item should always return Ok");
};
Expand All @@ -310,9 +310,9 @@ impl PlayerInventory {
}
}

// Try to add to hand slots (36-45) first, then the rest of the inventory (0-35)
// Try to add to hot bar (36-44) first, then the rest of the inventory (9-35)
// now try to add to empty slots
for slot in (36..=45).chain(0..36) {
for slot in (36..=44).chain(9..36) {
let Ok(add_slot) = self.try_add_to_slot(slot, &mut item, true) else {
unreachable!("try_add_item should always return Ok");
};
Expand Down

0 comments on commit 7490b44

Please sign in to comment.