@@ -79,6 +79,9 @@ public final class WaypointsHack extends Hack
7979 private boolean hasLoadedWorldData ;
8080 private BlockPos lastDeathAt ;
8181 private long lastDeathCreatedMs ;
82+ // Guard to avoid announcing the same death repeatedly while the
83+ // death screen is active (fired every tick).
84+ private boolean deathAnnounced = false ;
8285 // Track recent death times to avoid duplicates per player
8386 private final Map <UUID , Long > otherDeathCooldown = new HashMap <>();
8487 // Track current dead state for edge detection
@@ -274,6 +277,9 @@ public void onUpdate()
274277 {
275278 ensureWorldData ();
276279 updatePortalAutoRecording ();
280+ // Reset the death-announced guard once the player is alive again.
281+ if (deathAnnounced && MC .player != null && MC .player .getHealth () > 0 )
282+ deathAnnounced = false ;
277283 // Detect deaths of other players
278284 if (trackOtherDeaths .isChecked () && MC .level != null
279285 && MC .player != null )
@@ -687,6 +693,8 @@ public void onDeath()
687693 {
688694 if (MC .player == null )
689695 return ;
696+ if (deathAnnounced )
697+ return ;
690698
691699 BlockPos at = MC .player .blockPosition ().above (2 );
692700 long now = System .currentTimeMillis ();
@@ -696,9 +704,20 @@ public void onDeath()
696704
697705 // Optional death chat, regardless of creating a waypoint
698706 if (chatOnDeath .isChecked ())
699- MC .player .displayClientMessage (Component .literal (
700- "Died at " + at .getX () + ", " + at .getY () + ", " + at .getZ ()),
701- false );
707+ {
708+ // Mark that we've announced this death to avoid repeats while
709+ // the death screen remains open. Also guard against handling
710+ // our own injected chat in onReceivedMessage.
711+ sendingOwnChat = true ;
712+ try
713+ {
714+ MC .player .displayClientMessage (Component .literal ("Died at "
715+ + at .getX () + ", " + at .getY () + ", " + at .getZ ()), false );
716+ }finally
717+ {
718+ sendingOwnChat = false ;
719+ }
720+ }
702721
703722 if (createDeathWaypoints .isChecked ())
704723 {
@@ -718,6 +737,7 @@ public void onDeath()
718737
719738 lastDeathAt = at ;
720739 lastDeathCreatedMs = now ;
740+ deathAnnounced = true ;
721741 }
722742
723743 private WaypointDimension currentDim ()
0 commit comments