Count shield damage only for accepted hits and skip kills saved by a totem

This commit is contained in:
Kacpherek
2026-10-26 16:47:11 +01:00
parent 273729aac8
commit 49ad61035b
3 changed files with 7 additions and 9 deletions
+4 -1
View File
@@ -74,11 +74,14 @@ impl Game<'_> {
for e in events {
let (name, amount) = match e {
// LivingEntity.getDamageAfterMagicAbsorb (Resistance) and
// Player.actuallyHurt (absorption hearts), in tenths.
// Player.actuallyHurt (absorption hearts) and
// LivingEntity.hurtServer (the shield, only for an accepted
// hit), in tenths.
MotionEvent::Health(HealthEvent::Statistic { name, amount }) => {
match *name {
"resisted" => self.stats.custom("damage_resisted", *amount),
"absorbed" => self.stats.custom("damage_absorbed", *amount),
"blocked" => self.stats.custom("damage_blocked_by_shield", *amount),
_ => {}
}
continue;
+3 -1
View File
@@ -256,10 +256,12 @@ impl Game<'_> {
// ServerPlayer.awardKillScore: the blow that kills a player.
if hurt {
let died = match victim {
// A totem that fired is applied on the next tick_totem, so the
// host is still at zero health but is not dying.
Victim::Host => self
.player
.as_ref()
.is_some_and(|p| p.health.dead_or_dying()),
.is_some_and(|p| p.health.dead_or_dying() && !p.health.totem_used),
Victim::Guest(conn) => host
.hub
.guest(conn)
-7
View File
@@ -121,13 +121,6 @@ impl Game<'_> {
attacker: Option<u32>,
projectile: bool,
) {
// LivingEntity.hurtServer: the damage the shield took, in tenths.
if outcome.blocked > 0.0 {
self.stats.custom(
"damage_blocked_by_shield",
(outcome.blocked * 10.0).round() as i32,
);
}
let Some((slot, _)) = self.using else { return };
let Some(stack) = self.stack_in(slot).cloned() else {
return;