From c50557ea0ba2abb0c1476aa65faf12ee090478c7 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 16:29:05 +0100 Subject: [PATCH] Credit the projectile owner for explosion damage to mobs --- crates/horizon-client/src/game/combat.rs | 3 +++ crates/horizon-client/src/game/creatures.rs | 5 ++++- crates/horizon-client/src/game/explosion.rs | 6 +++++- crates/horizon-client/src/game/wither.rs | 5 ++++- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/crates/horizon-client/src/game/combat.rs b/crates/horizon-client/src/game/combat.rs index 106e0e1a1..3d0c34ff2 100644 --- a/crates/horizon-client/src/game/combat.rs +++ b/crates/horizon-client/src/game/combat.rs @@ -31,6 +31,9 @@ pub(super) struct CombatTracker { /// The mob exploding now (`ServerExplosion.source`): its team's friendly /// fire decides whom the blast may hurt. pub(super) explosion_source: Option, + /// The mob that owns the projectile exploding now (`getIndirectSourceEntity`): + /// the mobs the blast hurts record it as their attacker. + pub(super) explosion_owner: Option, /// The player's fall distance before this tick's movement (as of the /// end of the last one). fall_before: f64, diff --git a/crates/horizon-client/src/game/creatures.rs b/crates/horizon-client/src/game/creatures.rs index cd211ec48..48e029381 100644 --- a/crates/horizon-client/src/game/creatures.rs +++ b/crates/horizon-client/src/game/creatures.rs @@ -2283,7 +2283,10 @@ impl Game<'_> { if let Some(owner) = self.combat.projectile_owner { self.note_attacker("minecraft:explosion", owner); } - self.explode(atp, *power as f32)?; + self.combat.explosion_owner = self.combat.projectile_owner; + let result = self.explode(atp, *power as f32); + self.combat.explosion_owner = None; + result?; } ( ProjectileKind::Potion { diff --git a/crates/horizon-client/src/game/explosion.rs b/crates/horizon-client/src/game/explosion.rs index 6ecba3a54..675203517 100644 --- a/crates/horizon-client/src/game/explosion.rs +++ b/crates/horizon-client/src/game/explosion.rs @@ -393,7 +393,11 @@ impl Game<'_> { ); let source = horizon_client::mobs::Damage { kind: horizon_client::mobs::DamageKind::Explosion, - attacker: None, + attacker: self + .combat + .explosion_owner + .filter(|&o| o != m.id) + .map(horizon_client::mobs::Who::Mob), from: Some(center), }; if hurtable && !m.damage(damage(dist, exposure), source) { diff --git a/crates/horizon-client/src/game/wither.rs b/crates/horizon-client/src/game/wither.rs index 101818f68..996f55d1c 100644 --- a/crates/horizon-client/src/game/wither.rs +++ b/crates/horizon-client/src/game/wither.rs @@ -172,7 +172,10 @@ impl Game<'_> { if let Some(id) = owner { self.note_attacker("minecraft:explosion", id); } - self.explode(at, 1.0) + self.combat.explosion_owner = owner; + let result = self.explode(at, 1.0); + self.combat.explosion_owner = None; + result } } /// Wither skulls drawn as the skull model, blue when dangerous.