If the current durability of an item is less than zero. The durability bars starts to render backwards and can go off-screen. The more durability under zero, the longer the bar becomes.
In 1.19.3 and earlier. The durability bar would just be empty if the current durability is below zero.
Steps to Reproduce:
1. Give yourself an item that has durability (Armor, tools). With the damage tag set to a value greater than the total durability of the item.
/give @s minecraft:iron_helmet{Damage:10000}
2. Notice how the durability bar is rendering incorrectly.
Linked issues
is duplicated by 3
relates to 2
Attachments
Comments 2
I believe I've identified the source of the issue in the code.
MCP-Reborn 1.20, net.minecraft.world.item:
public int getBarWidth(ItemStack p_150900_) {
return Math.round(13.0F - (float)p_150900_.getDamageValue() * 13.0F / (float)this.maxDamage);
{{}}}
When the damage value is a negative number, the bar width flips on itself and outputs a negative number. To fix this, the getBarWidth value should have a minimum value of 0 set, so it doesn't extend backwards.
Confirmed.
[media][media]