@@ -70,6 +70,9 @@ public final class WaypointsHack extends Hack
7070 private boolean hasLoadedWorldData ;
7171 private BlockPos lastDeathAt ;
7272 private long lastDeathCreatedMs ;
73+ // Guard to avoid announcing the same death repeatedly while the
74+ // death screen is active (fired every tick).
75+ private boolean deathAnnounced = false ;
7376 // Track recent death times to avoid duplicates per player
7477 private final Map <UUID , Long > otherDeathCooldown = new HashMap <>();
7578 // Track current dead state for edge detection
@@ -265,6 +268,9 @@ public void onUpdate()
265268 {
266269 ensureWorldData ();
267270 updatePortalAutoRecording ();
271+ // Reset the death-announced guard once the player is alive again.
272+ if (deathAnnounced && MC .player != null && MC .player .getHealth () > 0 )
273+ deathAnnounced = false ;
268274 // Detect deaths of other players
269275 if (trackOtherDeaths .isChecked () && MC .level != null
270276 && MC .player != null )
@@ -678,6 +684,8 @@ public void onDeath()
678684 {
679685 if (MC .player == null )
680686 return ;
687+ if (deathAnnounced )
688+ return ;
681689
682690 BlockPos at = MC .player .blockPosition ().above (2 );
683691 long now = System .currentTimeMillis ();
@@ -687,9 +695,20 @@ public void onDeath()
687695
688696 // Optional death chat, regardless of creating a waypoint
689697 if (chatOnDeath .isChecked ())
690- MC .player .displayClientMessage (Component .literal (
691- "Died at " + at .getX () + ", " + at .getY () + ", " + at .getZ ()),
692- false );
698+ {
699+ // Mark that we've announced this death to avoid repeats while
700+ // the death screen remains open. Also guard against handling
701+ // our own injected chat in onReceivedMessage.
702+ sendingOwnChat = true ;
703+ try
704+ {
705+ MC .player .displayClientMessage (Component .literal ("Died at "
706+ + at .getX () + ", " + at .getY () + ", " + at .getZ ()), false );
707+ }finally
708+ {
709+ sendingOwnChat = false ;
710+ }
711+ }
693712
694713 if (createDeathWaypoints .isChecked ())
695714 {
@@ -709,6 +728,7 @@ public void onDeath()
709728
710729 lastDeathAt = at ;
711730 lastDeathCreatedMs = now ;
731+ deathAnnounced = true ;
712732 }
713733
714734 private WaypointDimension currentDim ()
0 commit comments