Skip to content

fix: damage triggers not applying if damage is fully blocked by absorption#18

Merged
Robotgiggle merged 1 commit into
Robotgiggle:mainfrom
pythonmcpi:fix_damage_triggers
Mar 17, 2026
Merged

fix: damage triggers not applying if damage is fully blocked by absorption#18
Robotgiggle merged 1 commit into
Robotgiggle:mainfrom
pythonmcpi:fix_damage_triggers

Conversation

@pythonmcpi

@pythonmcpi pythonmcpi commented Mar 16, 2026

Copy link
Copy Markdown
Contributor

Previously, the damage triggers only fire if damage is not entirely blocked by absorption. This runs contrary to player expectations (since the health bar still visually drops, invincibility frames are granted, and all the other usual damage things happen). This was due to a mixin injecting @At("TAIL"), which doesn't necessarily correspond to the bottom of the applyDamage function. Thus, post mixin injection, the code looks like this (obtained via -Dmixin.debug.export=true):
image
fireTriggersAfterDamage in PlayerEntityMixin (common) is placed inside the if statement condition.

This pull request changes the injection point to @At("RETURN"), which injects at all return points. Post mixin injection view with the PR changes:
image

fireTriggersAfterDamage doesn't actually fire the damage trigger if the player was invulnerable to the damage source, so the first inject is fine to leave in. The other two injection points are correct.
fireTriggersAfterDamage also fires the health decrease trigger, but only if the player is dead. No damage is dealt if the player is invulnerable, so those triggers will (correctly) not fire either.

@Robotgiggle Robotgiggle merged commit 88eb5c3 into Robotgiggle:main Mar 17, 2026
13 of 14 checks passed
@pythonmcpi pythonmcpi deleted the fix_damage_triggers branch March 17, 2026 04:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants