The bug
Silk Touch and Fortune enchantments on tools that have one durability left don't apply the enchantment's effect.
How to reproduce
Silk Touch
Get a grass block and place it down
Use the command:
/give @p minecraft:diamond_shovel{Enchantments:[{id:silk_touch,lvl:1}],Damage:1559}
Break grass block
→ ✔ Grass block is droppedPlace the grass block down again and break it
→ ❌ Dirt is Dropped
Fortune
Get two diamond ore block and place them down
Use the command:
/give @p minecraft:diamond_pickaxe{Enchantments:[{id:fortune,lvl:1000}],Damage:1559}
Break one diamond ore block
→ ✔ You get more than one diamondBreak the other diamond ore block
→ ❌ You only get one diamond
Linked issues
is duplicated by 6
relates to 1
Comments 7
In doing research into this bug to fix it in the Paper Minecraft server, I came across an interesting problem. Partway through the block break logic, the player's item stack count is set to 0. The issue with this is further down the item stack is cloned, but because item stacks with a count of 0 are not retained, a null stack is instead returned before determining the item entity that should be created. When breaking a grass block with a 1 durability silk touch shovel, because the original item stack is not available, the silk touch enchantment is no longer applied. The same can be said of fortune pickaxes.
sounds like the order of events needs to be switched around so the stack size is altered after the main action is complete, rather than before.
This has been fixed at some point in the 1.15 development phase (probably 19w44a, see MC-156197)
Can confirm. This issue clones MC-1565.