fix: correctly determine when to send death message instead of knockdown message

This commit is contained in:
Octol1ttle 2024-03-03 16:46:56 +05:00
parent 3b499b9f5c
commit 4e02f61903
Signed by: Octol1ttle
GPG key ID: B77C34313AEE1FFF
2 changed files with 6 additions and 4 deletions

View file

@ -70,10 +70,12 @@ public class KnockdownsEvents {
KnockdownsNetwork.sendToWorld(player.getServerWorld(), new PlayKnockedDownSoundS2CPacket(player.getX(), player.getY(), player.getZ()));
Text deathMessage = entity.getDamageTracker().getDeathMessage();
TranslatableTextContent content = (TranslatableTextContent) deathMessage.getContent();
Text replaced = Text.translatableWithFallback(content.getKey().replace("death.", "knockdown."), deathMessage.getString(), content.getArgs());
TranslatableTextContent deathContent = (TranslatableTextContent) deathMessage.getContent();
server.getPlayerManager().broadcast(replaced, false);
String knockdownKey = deathContent.getKey().replace("death.", "knockdown.");
Text knockdownMessage = Text.translatable(knockdownKey, deathContent.getArgs());
server.getPlayerManager().broadcast(!knockdownMessage.getString().equals(knockdownKey) ? knockdownMessage : deathMessage, false);
return EventResult.interruptFalse();
});

View file

@ -4,7 +4,7 @@ minecraft_version=1.20.1
enabled_platforms=fabric,forge
archives_base_name=knockdowns
mod_version=2.1.0
mod_version=2.1.1
maven_group=ru.octol1ttle.knockdowns
architectury_version=9.1.12