Credit the projectile owner for explosion damage to mobs
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user