Skip to content

fix: pets take no damage from their owner - #45

Merged
Nowkoo merged 1 commit into
mainfrom
fix/pets-ignore-owner-damage
Oct 21, 2026
Merged

Nowkoo merged 1 commit into
mainfrom
fix/pets-ignore-owner-damage

Conversation

@Nowkoo

@Nowkoo Nowkoo commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Problem

A player reported their cats dying from "fall damage" after using Warrior Dash to drop down a slope. Vanilla cats are immune to fall damage, and CoreProtect attributes both deaths (TF Main, 2026-10-21 20:30:36/37) to the owner, Archbishqp.

The cats were following their owner. They teleported next to the owner on landing while Warrior_Dash was still pulsing @EIR{r=2.5} every tick for 10 damage. A cat has 10 HP, so each died outright, and lostBody() permanently deleted the pet.

Change

PetListener.onOwnerDamage cancels EntityDamageByEntityEvent at LOWEST when the responsible player is the pet's owner account. The responsible player is the damage source's causing entity, falling back to the damager, then to a projectile's shooter. This covers:

  • melee
  • the owner's own projectiles
  • skill damage (MythicLib mmodamage) that names the caster as the causing entity, including any other area skill such as Warrior Lunge or Totem Mine

Because the event is cancelled early, the pet loses no mood and plays no hurt animation. Damage from other players, and the owner's damage to other owners' pets, are unchanged.

Tests

  • New: owner melee, projectile and skill damage are cancelled before other plugins see the event, with no mood loss and no animation.
  • New: damage from strangers, to other owners' pets and to unrelated mobs is unchanged.
  • Two existing tests used the owner as a generic attacker and now use a stranger, so they keep testing what they did before.
  • PetListenerCoverageTest: 33/33 passing locally. With the handler disabled, the new owner-damage test fails.
  • The full local suite on Windows shows the same environment-only failures as unmodified main (directory fsync AccessDeniedException, cascading into "Already mocking"). CI on Linux is the authoritative run.

🤖 Generated with Claude Code

Pets following their owner were teleported next to them while an area skill
was still active. Warrior Dash pulses every tick for 2.5 blocks and deals 10
damage, which kills a 10 HP cat outright, and the death deleted the pet.

Damage is now cancelled at LOWEST when the responsible player is the pet's
owner. That covers melee, the owner's projectiles and skill damage that names
the owner as its causing entity. Other players and other owners' pets are
unaffected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 21, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cf013e6c-42e5-40f1-bb13-c6d38990a5ca
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the size:S 10-29 effective changed lines (tests excluded in mixed PRs). label Oct 21, 2026
@Nowkoo

Nowkoo commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

Verified on TF Dev with this PR's CI artifact (companionpets-DEV-20261021-2114.jar, sha256 15d99d41…58e8, built from fb9edcd).

Setup:

  • A real bot player joined Dev.
  • A temporary probe registered two unmodeled cat pets in the live CompanionPets store: one owned by the bot and one owned by a random stranger as a control.
  • The probe traced every EntityDamageEvent priority on both bodies.

Results:

  • Owner's pet: damage attributed to the bot was already cancelled at LOWEST. This held both for a Bukkit DamageSource and for MythicLib's own DamageManager.damage(...), the path mmodamage/Warrior Dash uses (cause=ENTITY_ATTACK causing=CPOwnerDmg). Health and mood were unchanged.
  • Stranger's pet: the same damage passed LOWEST–HIGHEST uncancelled. RPCharacters' CharacterSelectionGuard then cancelled it, because the characterless bot was in character selection; this is unrelated to the change.
  • Uncaused damage (damage(2)) still hurt both cats (10 → 8), so the bodies stay damageable.

Cleanup: the probe was removed and Dev restarted. Dev's 7 saved pets kept the same IDs, owners and types.

@Nowkoo
Nowkoo merged commit e5e2727 into main Oct 21, 2026
3 checks passed
@Nowkoo
Nowkoo deleted the fix/pets-ignore-owner-damage branch October 21, 2026 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 effective changed lines (tests excluded in mixed PRs).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant