Skip to content

Commit

Permalink
Allow custom projectile damages through
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Aug 2, 2022
1 parent 886f8e4 commit cfaf8a0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main/java/org/mcmonkey/sentinel/SentinelTrait.java
Expand Up @@ -925,6 +925,9 @@ public void whenAttacksAreHappeningFromMyArrow(EntityDamageByEntityEvent event)
return;
}
double dam = getDamage(true);
if (damage < 0 && SentinelUtilities.approxEquals(dam, 1)) { // Allow default damage through for custom / external weapons
return;
}
double modder = event.getDamage(EntityDamageEvent.DamageModifier.BASE);
double rel = modder == 0.0 ? 1.0 : dam / modder;
event.setDamage(EntityDamageEvent.DamageModifier.BASE, dam);
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/org/mcmonkey/sentinel/SentinelUtilities.java
Expand Up @@ -570,4 +570,13 @@ public static boolean checkLineOfSightWithTransparency(Location start, Location
}
return checkLineOfSightWithTransparency(hit, end);
}

private final static double EPSILON = 0.0000001;

/**
* Returns true if "a == b" within a small epsilon margin (to compensate for Double value inaccuracies).
*/
public static boolean approxEquals(double a, double b) {
return Math.abs(a - b) < EPSILON;
}
}

0 comments on commit cfaf8a0

Please sign in to comment.