From 18003c98a684a2148f325985afb736293f2dbdb2 Mon Sep 17 00:00:00 2001 From: arsenicviscera Date: Sat, 14 Mar 2026 16:38:39 -0700 Subject: [PATCH] Crit Sound Now Plays On Death --- Minecraft.World/EntityEvent.h | 1 + Minecraft.World/LivingEntity.cpp | 22 ++++++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Minecraft.World/EntityEvent.h b/Minecraft.World/EntityEvent.h index ae80cd1b..20e363c6 100644 --- a/Minecraft.World/EntityEvent.h +++ b/Minecraft.World/EntityEvent.h @@ -7,6 +7,7 @@ public: static const BYTE HURT = 2; //New static const BYTE HURT_CRITICAL = 19; + static const BYTE DEATH_CRITICAL = 20; static const BYTE DEATH = 3; static const BYTE START_ATTACKING = 4; static const BYTE STOP_ATTACKING = 5; diff --git a/Minecraft.World/LivingEntity.cpp b/Minecraft.World/LivingEntity.cpp index 20967b7f..10811af7 100644 --- a/Minecraft.World/LivingEntity.cpp +++ b/Minecraft.World/LivingEntity.cpp @@ -859,7 +859,11 @@ bool LivingEntity::hurt(DamageSource *source, float dmg) MemSect(31); if (getHealth() <= 0) { - if (sound) playSound(getDeathSound(), getSoundVolume(), getVoicePitch()); + if (sound) { + //New: both death AND hurt sounds should play critical sound as well. + if (source->isCritical()) playSound(getCriticalSound(), getSoundVolume(), getVoicePitch()); + playSound(getDeathSound(), getSoundVolume(), getVoicePitch()); + }; die(source); } else @@ -934,7 +938,11 @@ void LivingEntity::die(DamageSource *source) } } - level->broadcastEntityEvent(shared_from_this(), EntityEvent::DEATH); + if (source->isCritical()) { + level->broadcastEntityEvent(shared_from_this(), EntityEvent::DEATH_CRITICAL); + } else { + level->broadcastEntityEvent(shared_from_this(), EntityEvent::DEATH); + } } void LivingEntity::dropEquipment(bool byPlayer, int playerBonusLevel) @@ -1209,18 +1217,24 @@ void LivingEntity::handleEntityEvent(byte id) { playSound(iHurtSound, getSoundVolume(), (random->nextFloat() - random->nextFloat()) * 0.2f + 1.0f); } - if(iCritSound!=-1 && id == EntityEvent::HURT_CRITICAL) + if(iCritSound!=-1 && (id == EntityEvent::HURT_CRITICAL)) { playSound(iCritSound, getSoundVolume(), (random->nextFloat() - random->nextFloat()) * 0.2f + 1.0f); } MemSect(0); hurt(DamageSource::genericSource, 0); } - else if (id == EntityEvent::DEATH) + else if ((id == EntityEvent::DEATH) || (id == EntityEvent::DEATH_CRITICAL)) { MemSect(31); // 4J-PB -added because villagers have no sounds int iDeathSound=getDeathSound(); + int iCritSound = getCriticalSound(); + + if (iCritSound != -1 && (id == EntityEvent::DEATH_CRITICAL)) + { + playSound(iCritSound, getSoundVolume(), (random->nextFloat() - random->nextFloat()) * 0.2f + 1.0f); + } if(iDeathSound!=-1) { playSound(iDeathSound, getSoundVolume(), (random->nextFloat() - random->nextFloat()) * 0.2f + 1.0f);