item pickup: a stack in the off hand fills before the inventory, as getSlotWithRemainingSpace does

Fixes #2865.
This commit is contained in:
iLostName committed 2026-10-28 06:52:28 +01:00
1 parent 56f968e11c
commit a967ca4340
1 file changed
+9 -2
+9 -2
View File
@@ -2317,12 +2317,19 @@ impl Game<'_> {
.items()
.get(&stack.item)
.map_or(64, |i| i.max_stack);
// Prefer the selected slot, then the hotbar, then the main inventory.
// getSlotWithRemainingSpace: the selected slot, the off hand, then
// the hotbar and the main inventory.
let order: Vec<usize> = std::iter::once(self.selected)
.chain(std::iter::once(shield::OFFHAND_SLOT))
.chain((0..36).filter(|&i| i != self.selected))
.collect();
for &i in &order {
if let Some(slot) = &mut self.inventory[i]
let slot = if i == shield::OFFHAND_SLOT {
&mut self.offhand
} else {
&mut self.inventory[i]
};
if let Some(slot) = slot
&& slot.same_item_same_components(&stack)
&& slot.count < max
{