Skip to content

Commit

Permalink
Check for damage invulnerability when simulating overcast
Browse files Browse the repository at this point in the history
*Normally* since overcast bypasses invuln this should never trigger, but weird interactions with mods can happen, like FAPI FakePlayers being invulnerable to all damage.
This checks for the sole exception of isInvulnerableTo checked by trulyHurt, so it should close the loophole as trulyHurt will forcibly set target's HP if it's invulnerable using another method.
This still has a possible TOCTTOU for free overcast, but it should be rare enough that it's not practically feasible to exploit.
  • Loading branch information
vgskye committed Feb 13, 2025
1 parent ef2cd28 commit 9c3ce5f
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ protected long extractMediaFromInventory(long costLeft, boolean allowOvercast, b
double healthToRemove = Math.max(costLeft / mediaToHealth, 0.5);
if (simulate) {
long simulatedRemovedMedia = Mth.ceil(Math.min(this.caster.getHealth(), healthToRemove) * mediaToHealth);
if (this.caster.isInvulnerableTo(this.caster.damageSources().source(HexDamageTypes.OVERCAST))) {
simulatedRemovedMedia = 0;
}
costLeft -= simulatedRemovedMedia;
} else {
var mediaAbleToCastFromHP = this.caster.getHealth() * mediaToHealth;
Expand Down

0 comments on commit 9c3ce5f

Please sign in to comment.