mojira.dev
MC-91886

Inconsistent stacking behavior when 1-9 hotkeying out of limited slots

Like in MC-91883, I'm just going to provide steps to reproduce:

1. /gamemode survival
2. /clear
3. /item replace entity @p armor.head with minecraft:carved_pumpkin
4. /item replace entity @p hotbar.1 with minecraft:carved_pumpkin 32
5. /item replace entity @p hotbar.2 with minecraft:carved_pumpkin 32
5. Open your inventory, move your mouse over the pumpkin in the helmet slot
6. Hit 2 on your keyboard and observe how item stack sizes in your hotbar do not change.
7. Hit 3 on your keyboard and observe how item stack size increases in the second hotbar slot and decreases in the first hotbar slot.

What's actually happening is: When using the 1-9 hotkey, it switches the item stacks between the two slots. Stack size limitation for the helmet slot dictates that only one item may move there, so only one of the 32 pumpkins is moved there, resulting in 31 pumpkins. Then the single pumpkin that was originally in the head slot is moved into the inventory: a slot for it is looked for because the slot we are hotkeying in is still occupied with 31 pumpkins. The game looks through the inventory to find a suitable spot for the single pumpkin to put in (a suitable slot is either an empty slot or a slot the pumpkin can be added to), finds the slot with 31 pumpkins in it and puts the pumpkin there.

The "problem" lies with the order in which a slot is looked for: The 9 hotbar slots are always searched left-to-right. This is why, when we pressed the 2 key, the stack sizes remained the same (the pumpkin from the helmet slot was put in the same slot where the other pumpkin went), and when we pressed the 3 key, the stack sizes changed (the pumpkin from the helmet slot went into the 2nd hotbar slot, the pumpkin that was put into the helmet slot came from the 3rd hotbar slot).

The item "to the left" of the hotkeyed stack can also be in the offhand.

Linked issues

Comments 13

Can confirm for 1.9.

Is this still an issue in the most recent versions (currently that is 1.10.2, or 16w42a) of Minecraft? If so, please update the affected versions and help us keeping this ticket updated from time to time.

I am unable to reproduce this issue in 20w49a.

This is still replicable by using carved pumpkins instead of pumpkins. I've updated the description to reflect it and also use the new /replace syntax.

3 more comments

Can confirm in 21w07a.

Can confirm in 1.16.5 and 21w08b.

Can confirm in 21w11a.

Here are the updated command usages for the third, fourth, and fifth reproduction steps:

/item replace entity @p armor.head with minecraft:carved_pumpkin
/item replace entity @p hotbar.1 with minecraft:carved_pumpkin 32
/item replace entity @p hotbar.2 with minecraft:carved_pumpkin 32

Can Confirm in 1.19.3 Release Candidate 3

Can Confirm in 1.19.2

[Mod] redstonehelper

(Unassigned)

Confirmed

Platform

Low

UI

Minecraft 15w44b, Minecraft 1.9, Minecraft 16w42a, Minecraft 17w06a, 20w07a, ..., 1.19.2, 1.19.3 Release Candidate 3, 1.19.3, 1.21.3, 24w46a

Retrieved