6363import com .google .gson .JsonObject ;
6464import com .mojang .blaze3d .vertex .PoseStack ;
6565import com .mojang .math .Axis ;
66+ import com .mojang .blaze3d .platform .GlConst ;
67+ import com .mojang .blaze3d .systems .RenderSystem ;
68+ import net .wurstclient .nicewurst .NiceWurstModule ;
6669import java .io .File ;
6770import java .io .FileReader ;
6871import java .io .FileWriter ;
@@ -467,14 +470,16 @@ public void onRender(PoseStack matrices, float partialTicks)
467470 {
468471 if (MC .level == null )
469472 return ;
470-
471473 ArrayList <ColoredBox > outlineBoxes = new ArrayList <>();
472474 ArrayList <ColoredBox > filledBoxes =
473475 fillShapes .isChecked () ? new ArrayList <>() : null ;
474476 ArrayList <ColoredPoint > tracerTargets =
475477 drawTracers .isChecked () ? new ArrayList <>() : null ;
478+ ArrayList <OverlayEntry > overlays = new ArrayList <>();
476479
477- // Render vault ESP boxes and simple status labels while hack is enabled
480+ // Render vault ESP boxes and collect simple status labels while hack
481+ // is enabled. Labels are collected and drawn after ESP geometry to
482+ // avoid depth/ordering issues.
478483 if (!vaults .isEmpty ())
479484 {
480485 for (VaultInfo v : vaults )
@@ -508,16 +513,21 @@ public void onRender(PoseStack matrices, float partialTicks)
508513 filledBoxes
509514 .add (new ColoredBox (vbox , withAlpha (vcolor , 0.18F )));
510515
511- // show simple status label above the vault
516+ // collect simple status label above the vault
512517 String status = describeVaultState (vstate );
513518 ArrayList <OverlayLine > lines = new ArrayList <>();
514519 lines .add (new OverlayLine ("Vault" , vcolor ));
515520 lines .add (new OverlayLine (status , 0xFFFFFFFF ));
516521 if (ominous && openedVaultKeys .contains (key ))
517522 lines .add (new OverlayLine ("Opened" , 0xFFDD4444 ));
518- Vec3 labelPos = Vec3 .atCenterOf (vpos ).add (0 , 1.0 , 0 );
523+ Vec3 target = Vec3 .atCenterOf (vpos );
524+ Vec3 labelPos = target .add (0 , 1.0 , 0 );
519525 labelPos = resolveLabelPosition (labelPos );
520- drawLabel (matrices , labelPos , lines , overlayScale .getValueF ());
526+ // Respect NiceWurst visibility rules for overlays: check the
527+ // original target point, but clamp label position separately.
528+ if (NiceWurstModule .shouldRenderTarget (target ))
529+ overlays .add (new OverlayEntry (target , labelPos , lines ,
530+ overlayScale .getValueF ()));
521531 }
522532 }
523533
@@ -547,12 +557,12 @@ public void onRender(PoseStack matrices, float partialTicks)
547557 drawActivationRadius (matrices , info , logic , color );
548558
549559 if (showVaultLink .isChecked () && info .vault () != null )
550- drawVaultLink (matrices , info , color );
560+ drawVaultLink (matrices , info , color , overlays );
551561
552562 // spawn tracers removed
553563
554564 if (showOverlay .isChecked ())
555- drawOverlay ( matrices , info , logic , state , color );
565+ collectOverlay ( info , logic , state , color , overlays );
556566 }
557567
558568 if (filledBoxes != null && !filledBoxes .isEmpty ())
@@ -562,6 +572,31 @@ public void onRender(PoseStack matrices, float partialTicks)
562572 if (tracerTargets != null && !tracerTargets .isEmpty ())
563573 RenderUtils .drawTracers (matrices , partialTicks , tracerTargets ,
564574 false );
575+
576+ // Draw collected overlays after geometry. Disable depth testing and
577+ // depth writes so glyphs are never clipped or overwritten by ESP
578+ // geometry. Respect NiceWurst visibility/label layer rules.
579+ if (!overlays .isEmpty ())
580+ {
581+ try
582+ {
583+ RenderSystem .depthFunc (GlConst .GL_ALWAYS );
584+ RenderSystem .depthMask (false );
585+
586+ for (OverlayEntry e : overlays )
587+ {
588+ // Check visibility against the original target point
589+ // (not the clamped label position) and skip if occluded.
590+ if (!NiceWurstModule .shouldRenderTarget (e .target ()))
591+ continue ;
592+ drawLabel (matrices , e .pos (), e .lines (), e .scale ());
593+ }
594+ }finally
595+ {
596+ RenderSystem .depthMask (true );
597+ RenderSystem .depthFunc (GlConst .GL_LEQUAL );
598+ }
599+ }
565600 }
566601
567602 private void drawActivationRadius (PoseStack matrices , TrialSpawnerInfo info ,
@@ -595,7 +630,7 @@ private void drawActivationRadius(PoseStack matrices, TrialSpawnerInfo info,
595630 }
596631
597632 private void drawVaultLink (PoseStack matrices , TrialSpawnerInfo info ,
598- int stateColor )
633+ int stateColor , List < OverlayEntry > overlays )
599634 {
600635 if (MC .level == null || info .vault () == null )
601636 return ;
@@ -613,12 +648,16 @@ private void drawVaultLink(PoseStack matrices, TrialSpawnerInfo info,
613648 String status = describeVaultState (state );
614649 List <OverlayLine > lines = List .of (new OverlayLine ("Vault" , stateColor ),
615650 new OverlayLine (status , color ));
651+ Vec3 target = end ;
616652 Vec3 labelPos = end .add (0 , 0.6 , 0 );
617- drawLabel (matrices , labelPos , lines , overlayScale .getValueF ());
653+ labelPos = resolveLabelPosition (labelPos );
654+ if (NiceWurstModule .shouldRenderTarget (target ))
655+ overlays .add (new OverlayEntry (target , labelPos , lines ,
656+ overlayScale .getValueF ()));
618657 }
619658
620- private void drawOverlay ( PoseStack matrices , TrialSpawnerInfo info ,
621- TrialSpawner logic , TrialSpawnerState state , int headerColor )
659+ private void collectOverlay ( TrialSpawnerInfo info , TrialSpawner logic ,
660+ TrialSpawnerState state , int headerColor , List < OverlayEntry > overlays )
622661 {
623662 if (MC .level == null )
624663 return ;
@@ -730,9 +769,12 @@ private void drawOverlay(PoseStack matrices, TrialSpawnerInfo info,
730769 lines .add (new OverlayLine ("Vault: " + vaultInfo , 0xFFFFFFFF ));
731770 }
732771
733- Vec3 labelPos = Vec3 .atCenterOf (info .pos ()).add (0 , 1.6 , 0 );
772+ Vec3 target = Vec3 .atCenterOf (info .pos ());
773+ Vec3 labelPos = target .add (0 , 1.6 , 0 );
734774 labelPos = resolveLabelPosition (labelPos );
735- drawLabel (matrices , labelPos , lines , overlayScale .getValueF ());
775+ if (NiceWurstModule .shouldRenderTarget (target ))
776+ overlays .add (new OverlayEntry (target , labelPos , lines ,
777+ overlayScale .getValueF ()));
736778 }
737779
738780 private void drawLabel (PoseStack matrices , Vec3 position ,
@@ -767,7 +809,8 @@ private void drawLabel(PoseStack matrices, Vec3 position,
767809 {
768810 OverlayLine line = lines .get (i );
769811 int y = i * lineHeight ;
770- DisplayMode layerType = DisplayMode .SEE_THROUGH ;
812+ DisplayMode layerType =
813+ NiceWurstModule .enforceTextLayer (DisplayMode .SEE_THROUGH );
771814 tr .drawInBatch (line .text (), x , y , line .color (), false ,
772815 matrices .last ().pose (), vcp , layerType , bg , 0xF000F0 );
773816 }
@@ -1263,6 +1306,10 @@ private record VaultInfo(BlockPos pos)
12631306 private record OverlayLine (String text , int color )
12641307 {}
12651308
1309+ private record OverlayEntry (Vec3 target , Vec3 pos , List <OverlayLine > lines ,
1310+ float scale )
1311+ {}
1312+
12661313 private enum TrialStatus
12671314 {
12681315 IDLE ,
0 commit comments