Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: try_add_item #540

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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