Credit the projectile owner for explosion damage to mobs

This commit is contained in:
Kacpherek
2026-10-26 16:29:05 +01:00
parent 9c427dfae0
commit c50557ea0b
4 changed files with 16 additions and 3 deletions
+3
View File
@@ -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<u32>,
/// The mob that owns the projectile exploding now (`getIndirectSourceEntity`):
/// the mobs the blast hurts record it as their attacker.
pub(super) explosion_owner: Option<u32>,
/// The player's fall distance before this tick's movement (as of the
/// end of the last one).
fall_before: f64,
+4 -1
View File
@@ -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 {
+5 -1
View File
@@ -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) {
+4 -1
View File
@@ -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.