Tool durability is off-by-one
The bug
Tool and armor durability allows for items with 0 durability, and only breaks after the next use. This doesn't make much sense: a tool with 100 durability should have 100 uses left, but it actually has 101. Likewise, a tool with its max damage on it should be broken, as the next use would be too much damage and so it shouldn't be able to be used again.
In other words: tools/armor should break at 0 durability, not at -1 durability.
Code Analysis
The fix is very simple. Using the Forge for 1.12.1 names, in the ItemStack#attemptDamageItem() method, it currently returns this:
return getItemDamage() > getMaxDamage();
Instead, it should return this:
return getItemDamage() >= getMaxDamage();
Just a "greater than" changed to a "greater than or equal to" fixes the problem everywhere.
Linked Issues
relates to7
Created Issue:
Tool durability is off-by-one
Tool and armor durability allows for items with 0 durability, and only breaks after the next use. This doesn't make much sense: a tool with 100 durability should have 100 uses left, but it actually has 101. Likewise, a tool with its max damage on it should be broken, as the next use would be too much damage and so it shouldn't be able to be used again.
In other words: tools/armor should break at 0 durability, not at -1 durability.
Code Analysis
The fix is very simple. Using the Forge for 1.12.1 names, in the ItemStack#attemptDamageItem() method, it currently returns this:
return getItemDamage() > getMaxDamage();
Instead, it should return this:
return getItemDamage() >= getMaxDamage();
Just a "greater than" changed to a "greater than or equal to" fixes the problem everywhere.
Tool and armor durability allows for items with 0 durability, and only breaks after the next use. This doesn't make much sense: a tool with 100 durability should have 100 uses left, but it actually has 101. Likewise, a tool with its max damage on it should be broken, as the next use would be too much damage and so it shouldn't be able to be used again.
In other words: tools/armor should break at 0 durability, not at -1 durability.
Code Analysis
The fix is very simple. Using the Forge for 1.12.1 names, in the ItemStack#attemptDamageItem() method, it currently returns this:
return getItemDamage() > getMaxDamage();
Instead, it should return this:
return getItemDamage() >= getMaxDamage();
Just a "greater than" changed to a "greater than or equal to" fixes the problem everywhere.
The bug
Tool and armor durability allows for items with 0 durability, and only breaks after the next use. This doesn't make much sense: a tool with 100 durability should have 100 uses left, but it actually has 101. Likewise, a tool with its max damage on it should be broken, as the next use would be too much damage and so it shouldn't be able to be used again.
In other words: tools/armor should break at 0 durability, not at -1 durability.
Code Analysis
The fix is very simple. Using the Forge for 1.12.1 names, in the ItemStack#attemptDamageItem() method, it currently returns this:
return getItemDamage() > getMaxDamage();
Instead, it should return this:
return getItemDamage() >= getMaxDamage();
Just a "greater than" changed to a "greater than or equal to" fixes the problem everywhere.
relates to
relates to
relates to
relates to
relates to
relates to
relates to
The bug
When killing a mob which can drop weapons, tools or armor, the dropped item is randomly damaged. Rarely the remaining durability of the item is 0, however that durability is not valid anymore, see MC-120664. Normally in Survival the lowest possible durability is 1, after that the item breaks.
Therefore mobs should also drop items with a durability of at least 1.
How to reproduce
- Enchant a sword with looting (and optionally sharpness)
- Kill multiple zombified piglins
- Pick up their dropped golden swords
Some of them have a durability of 0
See MC-120664
The bug
Since the fix of MC-120664, all items added before 18w30b have 1 less usage than before it was fixed. In versions before 1.13.1, a wooden pickaxe would mine 60 blocks (the pickaxe broke at -1). In versions 18w30b and above, a wooden pickaxe would now mine 59 blocks (the pickaxe does not break at 0 because of MC-120664, but the durability is still 59 instead of 60 for 60 mining usage).
How to reproduce
- Use the command in 1.13
/give @p minecraft:wooden_pickaxe{Damage:58} - You can break any block 2 times before the pickaxe breaks
- Use the same command in 18w30b or any version above
→
It breaks at 0 as expected, but you only had 59 usage instead of 60
The bug
When a trident has one durability remaining, it can be used. This causes it to break in the hand but still throw a trident entity.
Tridents are intended to disallow use when they are about to break:
// TridentItem#use if (itemStack.getDamageValue() >= itemStack.getMaxDamage()) { return InteractionResultHolder.fail(itemStack); }
However, this only prevents tridents with 0 durability from being thrown, rather than tridents with 1 durability.
This behavior broke when MC-120664 was fixed.
How to reproduce
/give @p trident{Damage:250}
/give @p trident{Damage:249}
Try to use the first trident (
you can't)
Try to use the second trident (
you can, it throws and breaks weirdly)
I think all items/armour have a +1 to their durability, which is probably related to MC-120664 (and isn't too relevant in this ticket).
The bug
The durability bar used by damageable items can appear completely empty even in cases where it has remaining uses.
I consider this to be an issue for much the same reason as MC-120664 was fixed: empty durability should imply the tool is no longer usable at all, rather than having a tiny pool of residual uses.
How to reproduce
Have an item, preferably one with high base durability, that is a small matter of uses (greater than one) from breaking.
Expected results
As the item can still be used, the durability bar should appear at its lowest level, but not empty (i.e. one red pixel). Empty durability bars should only be used if the durability is 0 or a negative number.
Actual results
The tool can still be used even when the durability bar looks empty, even though this logically doesn't make much sense.
Code analysis
Code analysis by Apollo can be found in this comment.
Same as MC-120664, but in Bedrock Edition.
For example, the durability of golden sword is 32, but it can use 33 times.
Confirmed
Confirmed, might be intended though.
If intended, it should be documented on the Official Minecraft Wiki, as right now it doesn't match the current game state.
The wiki is unofficial and is written by community members. Feel free to update it yourself.
Lost my perfect pick because of this ;-; didn't know this had changed and stupidly tried to use it to the end before fixing it, why change such trivial things which could have such important consequences?