item pickup: a stack in the off hand fills before the inventory, as getSlotWithRemainingSpace does
Fixes #2865.
This commit is contained in:
@@ -2317,12 +2317,19 @@ impl Game<'_> {
|
|||||||
.items()
|
.items()
|
||||||
.get(&stack.item)
|
.get(&stack.item)
|
||||||
.map_or(64, |i| i.max_stack);
|
.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)
|
let order: Vec<usize> = std::iter::once(self.selected)
|
||||||
|
.chain(std::iter::once(shield::OFFHAND_SLOT))
|
||||||
.chain((0..36).filter(|&i| i != self.selected))
|
.chain((0..36).filter(|&i| i != self.selected))
|
||||||
.collect();
|
.collect();
|
||||||
for &i in &order {
|
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.same_item_same_components(&stack)
|
||||||
&& slot.count < max
|
&& slot.count < max
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user