mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2025-02-25 15:11:20 +01:00
!Fixed durability display
This commit is contained in:
parent
ac35eb5553
commit
fefdb76b8c
@ -88,7 +88,7 @@ public class DurabilityItem {
|
|||||||
|
|
||||||
public DurabilityItem addDurability(int gain) {
|
public DurabilityItem addDurability(int gain) {
|
||||||
Validate.isTrue(gain > 0, "Durability gain must be greater than 0");
|
Validate.isTrue(gain > 0, "Durability gain must be greater than 0");
|
||||||
durability = Math.max(0, Math.min(durability + gain, getMaxDurability()));
|
durability = Math.max(0, Math.min(durability + gain, maxDurability));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ public class DurabilityItem {
|
|||||||
if (getUnbreakingLevel() > 0 && random.nextInt(getUnbreakingLevel()) > 0)
|
if (getUnbreakingLevel() > 0 && random.nextInt(getUnbreakingLevel()) > 0)
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
addDurability(-loss);
|
durability = Math.max(0, Math.min(durability - loss, maxDurability));
|
||||||
|
|
||||||
// When the item breaks
|
// When the item breaks
|
||||||
if (durability <= 0) {
|
if (durability <= 0) {
|
||||||
@ -126,9 +126,8 @@ public class DurabilityItem {
|
|||||||
* issues. Also makes sure the item can be mended using the vanilla
|
* issues. Also makes sure the item can be mended using the vanilla
|
||||||
* enchant.
|
* enchant.
|
||||||
*/
|
*/
|
||||||
double ratio = (double) durability / maxDurability;
|
int damage = durability == maxDurability ? 0
|
||||||
int damage = (int) ((1. - ratio) * nbtItem.getItem().getType().getMaxDurability());
|
: Math.max(1, (int) ((1. - ((double) durability / maxDurability)) * nbtItem.getItem().getType().getMaxDurability()));
|
||||||
damage = Math.max(durability == maxDurability ? 1 : 0, damage);
|
|
||||||
nbtItem.addTag(new ItemTag("MMOITEMS_DURABILITY", durability), new ItemTag("Damage", damage));
|
nbtItem.addTag(new ItemTag("MMOITEMS_DURABILITY", durability), new ItemTag("Damage", damage));
|
||||||
|
|
||||||
return nbtItem.toItem();
|
return nbtItem.toItem();
|
||||||
|
Loading…
Reference in New Issue
Block a user