Fix durability bar not respecting an item's custom max damage (#8482)

This commit is contained in:
sciwhiz12 authored and GitHub committed 2022-03-06 14:32:36 +00:00
1 parent 898696d770
commit cdd91968b4
1 file changed
+15
@@ -44,6 +44,21 @@
public final int m_41462_() {
return this.f_41371_;
}
@@ -166,11 +_,12 @@
}
public int m_142158_(ItemStack p_150900_) {
- return Math.round(13.0F - (float)p_150900_.m_41773_() * 13.0F / (float)this.f_41371_);
+ return Math.round(13.0F - (float)p_150900_.m_41773_() * 13.0F / (float)this.getMaxDamage(p_150900_));
}
public int m_142159_(ItemStack p_150901_) {
- float f = Math.max(0.0F, ((float)this.f_41371_ - (float)p_150901_.m_41773_()) / (float)this.f_41371_);
+ float stackMaxDamage = this.getMaxDamage(p_150901_);
+ float f = Math.max(0.0F, (stackMaxDamage - (float)p_150901_.m_41773_()) / stackMaxDamage);
return Mth.m_14169_(f / 3.0F, 1.0F, 1.0F);
}
@@ -227,10 +_,12 @@
}