Skip to content

Commit ba540ad

Browse files
feat: yml skills
1 parent 275cb9c commit ba540ad

26 files changed

Lines changed: 8228 additions & 15231 deletions

File tree

commons/src/main/java/net/swofty/commons/statistics/ItemStatistics.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,25 @@ public String toString() {
4343
double additiveValue = statisticsAdditive.getOrDefault(stat, 0D);
4444
double multiplicativeValue = statisticsMultiplicative.getOrDefault(stat, 0D);
4545

46-
if (baseValue != 0 || additiveValue != 0 || multiplicativeValue != 0) {
46+
// For multiplicative, 1.0 is the neutral element (like 0 for addition)
47+
// Use epsilon comparison to handle floating point drift
48+
boolean hasBase = Math.abs(baseValue) > 1e-9;
49+
boolean hasAdditive = Math.abs(additiveValue) > 1e-9;
50+
boolean hasMultiplicative = Math.abs(multiplicativeValue - 1.0) > 1e-9 && Math.abs(multiplicativeValue) > 1e-9;
51+
52+
if (hasBase || hasAdditive || hasMultiplicative) {
4753
builder.append(stat.name()).append(":");
4854
boolean needsComma = false;
49-
if (baseValue != 0) {
55+
if (hasBase) {
5056
builder.append("B").append(baseValue);
5157
needsComma = true;
5258
}
53-
if (additiveValue != 0) {
59+
if (hasAdditive) {
5460
if (needsComma) builder.append(",");
5561
builder.append("A").append(additiveValue);
5662
needsComma = true;
5763
}
58-
if (multiplicativeValue != 0) {
64+
if (hasMultiplicative) {
5965
if (needsComma) builder.append(",");
6066
builder.append("M").append(multiplicativeValue);
6167
}

0 commit comments

Comments
 (0)