Skip to content

Commit 3a55b30

Browse files
committed
TrialSpawnerESP Fix
1 parent 5d18dcb commit 3a55b30

File tree

2 files changed

+83
-29
lines changed

2 files changed

+83
-29
lines changed

src/main/java/net/wurstclient/hacks/TrialSpawnerEspHack.java

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
import net.wurstclient.util.RenderUtils;
5858
import net.wurstclient.util.RenderUtils.ColoredBox;
5959
import net.wurstclient.util.RenderUtils.ColoredPoint;
60+
import net.wurstclient.nicewurst.NiceWurstModule;
6061
import net.wurstclient.util.chunk.ChunkUtils;
6162
import com.google.gson.Gson;
6263
import com.google.gson.GsonBuilder;
@@ -474,6 +475,7 @@ public void onRender(PoseStack matrices, float partialTicks)
474475
fillShapes.isChecked() ? new ArrayList<>() : null;
475476
ArrayList<ColoredPoint> tracerTargets =
476477
drawTracers.isChecked() ? new ArrayList<>() : null;
478+
ArrayList<OverlayEntry> overlays = new ArrayList<>();
477479

478480
// Render vault ESP boxes and simple status labels while hack is enabled
479481
if(!vaults.isEmpty())
@@ -516,9 +518,10 @@ public void onRender(PoseStack matrices, float partialTicks)
516518
lines.add(new OverlayLine(status, 0xFFFFFFFF));
517519
if(ominous && openedVaultKeys.contains(key))
518520
lines.add(new OverlayLine("Opened", 0xFFDD4444));
519-
Vec3 labelPos = Vec3.atCenterOf(vpos).add(0, 1.0, 0);
520-
labelPos = resolveLabelPosition(labelPos);
521-
drawLabel(matrices, labelPos, lines, overlayScale.getValueF());
521+
Vec3 original = Vec3.atCenterOf(vpos).add(0, 1.0, 0);
522+
Vec3 resolved = resolveLabelPosition(original);
523+
overlays.add(new OverlayEntry(original, resolved, lines,
524+
overlayScale.getValueF()));
522525
}
523526
}
524527

@@ -548,12 +551,12 @@ public void onRender(PoseStack matrices, float partialTicks)
548551
drawActivationRadius(matrices, info, logic, color);
549552

550553
if(showVaultLink.isChecked() && info.vault() != null)
551-
drawVaultLink(matrices, info, color);
554+
drawVaultLink(matrices, info, color, overlays);
552555

553556
// spawn tracers removed
554557

555558
if(showOverlay.isChecked())
556-
drawOverlay(matrices, info, logic, state, color);
559+
drawOverlay(matrices, info, logic, state, color, overlays);
557560
}
558561

559562
if(filledBoxes != null && !filledBoxes.isEmpty())
@@ -563,6 +566,19 @@ public void onRender(PoseStack matrices, float partialTicks)
563566
if(tracerTargets != null && !tracerTargets.isEmpty())
564567
RenderUtils.drawTracers(matrices, partialTicks, tracerTargets,
565568
false);
569+
570+
// draw overlays after all ESP geometry so labels are not overwritten
571+
java.util.HashSet<BlockPos> drawn = new java.util.HashSet<>();
572+
for(OverlayEntry e : overlays)
573+
{
574+
if(!NiceWurstModule.shouldRenderTarget(e.original()))
575+
continue;
576+
BlockPos key = BlockPos.containing(e.original());
577+
if(drawn.contains(key))
578+
continue;
579+
drawn.add(key);
580+
drawLabel(matrices, e.resolved(), e.lines(), e.scale());
581+
}
566582
}
567583

568584
private void drawActivationRadius(PoseStack matrices, TrialSpawnerInfo info,
@@ -596,7 +612,7 @@ private void drawActivationRadius(PoseStack matrices, TrialSpawnerInfo info,
596612
}
597613

598614
private void drawVaultLink(PoseStack matrices, TrialSpawnerInfo info,
599-
int stateColor)
615+
int stateColor, ArrayList<OverlayEntry> overlays)
600616
{
601617
if(MC.level == null || info.vault() == null)
602618
return;
@@ -614,12 +630,15 @@ private void drawVaultLink(PoseStack matrices, TrialSpawnerInfo info,
614630
String status = describeVaultState(state);
615631
List<OverlayLine> lines = List.of(new OverlayLine("Vault", stateColor),
616632
new OverlayLine(status, color));
617-
Vec3 labelPos = end.add(0, 0.6, 0);
618-
drawLabel(matrices, labelPos, lines, overlayScale.getValueF());
633+
Vec3 original = end.add(0, 0.6, 0);
634+
Vec3 resolved = resolveLabelPosition(original);
635+
overlays.add(new OverlayEntry(original, resolved, lines,
636+
overlayScale.getValueF()));
619637
}
620638

621639
private void drawOverlay(PoseStack matrices, TrialSpawnerInfo info,
622-
TrialSpawner logic, TrialSpawnerState state, int headerColor)
640+
TrialSpawner logic, TrialSpawnerState state, int headerColor,
641+
ArrayList<OverlayEntry> overlays)
623642
{
624643
if(MC.level == null)
625644
return;
@@ -731,9 +750,10 @@ private void drawOverlay(PoseStack matrices, TrialSpawnerInfo info,
731750
lines.add(new OverlayLine("Vault: " + vaultInfo, 0xFFFFFFFF));
732751
}
733752

734-
Vec3 labelPos = Vec3.atCenterOf(info.pos()).add(0, 1.6, 0);
735-
labelPos = resolveLabelPosition(labelPos);
736-
drawLabel(matrices, labelPos, lines, overlayScale.getValueF());
753+
Vec3 original = Vec3.atCenterOf(info.pos()).add(0, 1.6, 0);
754+
Vec3 resolved = resolveLabelPosition(original);
755+
overlays.add(new OverlayEntry(original, resolved, lines,
756+
overlayScale.getValueF()));
737757
}
738758

739759
private void drawLabel(PoseStack matrices, Vec3 position,
@@ -768,7 +788,8 @@ private void drawLabel(PoseStack matrices, Vec3 position,
768788
{
769789
OverlayLine line = lines.get(i);
770790
int y = i * lineHeight;
771-
DisplayMode layerType = DisplayMode.SEE_THROUGH;
791+
DisplayMode layerType =
792+
NiceWurstModule.enforceTextLayer(DisplayMode.SEE_THROUGH);
772793
tr.drawInBatch(line.text(), x, y, line.color(), false,
773794
matrices.last().pose(), vcp, layerType, bg, 0xF000F0);
774795
}
@@ -1264,6 +1285,10 @@ private record VaultInfo(BlockPos pos)
12641285
private record OverlayLine(String text, int color)
12651286
{}
12661287

1288+
private record OverlayEntry(Vec3 original, Vec3 resolved,
1289+
List<OverlayLine> lines, float scale)
1290+
{}
1291+
12671292
private enum TrialStatus
12681293
{
12691294
IDLE,

src/main/java/net/wurstclient/util/RenderUtils.java

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,40 @@ public static RegionPos getCameraRegion()
8585
return RegionPos.of(getCameraBlockPos());
8686
}
8787

88+
/**
89+
* Returns true if any of several sample points on the given box are visible
90+
* according to NiceWurstModule.shouldRenderTarget(...).
91+
* Samples: center, four top corners, and a point one block above center.
92+
*/
93+
public static boolean isBoxVisible(AABB box)
94+
{
95+
if(box == null)
96+
return true;
97+
98+
Vec3 center = box.getCenter();
99+
// sample center
100+
if(NiceWurstModule.shouldRenderTarget(center))
101+
return true;
102+
103+
// point above center
104+
if(NiceWurstModule
105+
.shouldRenderTarget(new Vec3(center.x, center.y + 1.0, center.z)))
106+
return true;
107+
108+
// four top corners
109+
double y = box.maxY;
110+
if(NiceWurstModule.shouldRenderTarget(new Vec3(box.minX, y, box.minZ)))
111+
return true;
112+
if(NiceWurstModule.shouldRenderTarget(new Vec3(box.maxX, y, box.minZ)))
113+
return true;
114+
if(NiceWurstModule.shouldRenderTarget(new Vec3(box.minX, y, box.maxZ)))
115+
return true;
116+
if(NiceWurstModule.shouldRenderTarget(new Vec3(box.maxX, y, box.maxZ)))
117+
return true;
118+
119+
return false;
120+
}
121+
88122
public static MultiBufferSource.BufferSource getVCP()
89123
{
90124
return WurstClient.MC.renderBuffers().bufferSource();
@@ -343,7 +377,7 @@ public static void drawSolidBox(PoseStack matrices, AABB box, int color,
343377
boolean depthTest)
344378
{
345379
boolean overlay = NiceWurstModule.shouldOverlayEntityShapes();
346-
if(overlay && !NiceWurstModule.shouldRenderTarget(box.getCenter()))
380+
if(overlay && !isBoxVisible(box))
347381
return;
348382

349383
if(!overlay)
@@ -372,7 +406,7 @@ public static void drawSolidBoxes(PoseStack matrices, List<AABB> boxes,
372406
boolean rendered = false;
373407
for(AABB box : boxes)
374408
{
375-
if(overlay && !NiceWurstModule.shouldRenderTarget(box.getCenter()))
409+
if(overlay && !isBoxVisible(box))
376410
continue;
377411

378412
drawSolidBox(matrices, buffer, box.move(camOffset), color);
@@ -397,8 +431,7 @@ public static void drawSolidBoxes(PoseStack matrices,
397431
boolean rendered = false;
398432
for(ColoredBox box : boxes)
399433
{
400-
if(overlay
401-
&& !NiceWurstModule.shouldRenderTarget(box.box().getCenter()))
434+
if(overlay && !isBoxVisible(box.box()))
402435
continue;
403436

404437
drawSolidBox(matrices, buffer, box.box().move(camOffset),
@@ -471,7 +504,7 @@ public static void drawOutlinedOctahedrons(PoseStack matrices,
471504
boolean rendered = false;
472505
for(AABB box : boxes)
473506
{
474-
if(overlay && !NiceWurstModule.shouldRenderTarget(box.getCenter()))
507+
if(overlay && !isBoxVisible(box))
475508
continue;
476509

477510
drawOutlinedOctahedron(matrices, buffer, box.move(camOffset),
@@ -497,8 +530,7 @@ public static void drawOutlinedOctahedrons(PoseStack matrices,
497530
boolean rendered = false;
498531
for(ColoredBox box : boxes)
499532
{
500-
if(overlay
501-
&& !NiceWurstModule.shouldRenderTarget(box.box().getCenter()))
533+
if(overlay && !isBoxVisible(box.box()))
502534
continue;
503535

504536
drawOutlinedOctahedron(matrices, buffer, box.box().move(camOffset),
@@ -524,7 +556,7 @@ public static void drawSolidOctahedrons(PoseStack matrices,
524556
boolean rendered = false;
525557
for(AABB box : boxes)
526558
{
527-
if(overlay && !NiceWurstModule.shouldRenderTarget(box.getCenter()))
559+
if(overlay && !isBoxVisible(box))
528560
continue;
529561

530562
drawSolidOctahedron(matrices, buffer, box.move(camOffset), color);
@@ -549,8 +581,7 @@ public static void drawSolidOctahedrons(PoseStack matrices,
549581
boolean rendered = false;
550582
for(ColoredBox box : boxes)
551583
{
552-
if(overlay
553-
&& !NiceWurstModule.shouldRenderTarget(box.box().getCenter()))
584+
if(overlay && !isBoxVisible(box.box()))
554585
continue;
555586

556587
drawSolidOctahedron(matrices, buffer, box.box().move(camOffset),
@@ -688,7 +719,7 @@ public static void drawOutlinedBox(PoseStack matrices, AABB box, int color,
688719
boolean depthTest)
689720
{
690721
boolean overlay = NiceWurstModule.shouldOverlayEntityShapes();
691-
if(overlay && !NiceWurstModule.shouldRenderTarget(box.getCenter()))
722+
if(overlay && !isBoxVisible(box))
692723
return;
693724

694725
if(!overlay)
@@ -717,7 +748,7 @@ public static void drawOutlinedBoxes(PoseStack matrices, List<AABB> boxes,
717748
boolean rendered = false;
718749
for(AABB box : boxes)
719750
{
720-
if(overlay && !NiceWurstModule.shouldRenderTarget(box.getCenter()))
751+
if(overlay && !isBoxVisible(box))
721752
continue;
722753

723754
drawOutlinedBox(matrices, buffer, box.move(camOffset), color);
@@ -742,8 +773,7 @@ public static void drawOutlinedBoxes(PoseStack matrices,
742773
boolean rendered = false;
743774
for(ColoredBox box : boxes)
744775
{
745-
if(overlay
746-
&& !NiceWurstModule.shouldRenderTarget(box.box().getCenter()))
776+
if(overlay && !isBoxVisible(box.box()))
747777
continue;
748778

749779
drawOutlinedBox(matrices, buffer, box.box().move(camOffset),
@@ -772,8 +802,7 @@ public static void drawOutlinedBoxes(PoseStack matrices,
772802
boolean rendered = false;
773803
for(ColoredBox box : boxes)
774804
{
775-
if(overlay
776-
&& !NiceWurstModule.shouldRenderTarget(box.box().getCenter()))
805+
if(overlay && !isBoxVisible(box.box()))
777806
continue;
778807

779808
drawOutlinedBox(matrices, buffer, box.box().move(camOffset),

0 commit comments

Comments
 (0)