Skip to content

Commit 2d9c657

Browse files
committed
Improve mob health rounding
1 parent 2400b5b commit 2d9c657

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

common/src/main/java/net/dungeon_difficulty/logic/EntityScaling.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ private static void apply(PatternMatching.EntityScaleResult scaling, LivingEntit
7777
}
7878

7979
var modifierValue = modifier.randomizedValue(level);
80+
var roundingUnit = modifier.value * 0.25F;
81+
modifierValue = (float) MathHelper.round(modifierValue, roundingUnit);
8082

8183
for (var attribute: matchingAttributes) {
8284
var operation = switch (modifier.operation) {

common/src/main/java/net/dungeon_difficulty/logic/MathHelper.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
public class MathHelper {
44
public static double round(double value, double unit) {
5-
return Math.round(value / unit) * unit;
5+
// return Math.round( value / unit ) * unit;
6+
double scale = 1.0 / unit;
7+
return Math.round(value * scale) / scale;
68
}
79

810
public static float clamp(float value, float min, float max) {

0 commit comments

Comments
 (0)