- /give @p sapling 1 0
- /give @p sapling 1 1
- /clear @p sapling 1 1
You end up with 1 oak sapling in your inventory.
You end up with 1 spruce sapling in your inventory.
The /clear command has to do 2 things:
(1) Determine that the correct item is in the inventory.
(2) Remove the correct item from the inventory.
The bug here is that after it correctly performs (1) it ignores the [data] argument when doing (2) and removes the first matching item type that it finds. So, in the reproduction steps above,
- If you skip step #3 then the command in step #4 will fail, because (1) works correctly.
- If you run step #3 before step #2 then you will get the expected result and not see the bug, apparently because (2) checks inventory slots in order from first to last.
- If you select the hotbar slot with the spruce sapling after step #3 (i.e. hold the item in the main hand) then you will get the expected result and not see the bug, apparently because (2) always begins with whatever hotbar slot is currently selected (i.e. with the item held in the main hand), then it proceeds through the hotbar and inventory slots.