Skip to content

Commit c0116ac

Browse files
committed
ItemHandler ESP Fix
1 parent d858761 commit c0116ac

File tree

3 files changed

+31
-10
lines changed

3 files changed

+31
-10
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ Because so many of these mods are entirely original, I plan to release some of t
293293
- Pick: reject (drop) everything except the selected types (only selected types will be picked up).
294294
- Reject: reject the selected types and drop them.
295295
- Trace Selected Items: toggles tracing for selected types (uses ItemESP world render pass to draw rainbow tracer lines and ESP boxes).
296+
- Works independantly of ItemESP
296297
- Adjustable distance for item detection.
297298
- Adjustable font scale setting (scales text and popup icon size).
298299
- Adjustable Popup HUD display offset X/Y

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,15 @@ private int getSpecialARGB(int alpha)
600600
return RenderUtils.toIntColor(rgb, alpha / 255f);
601601
}
602602

603+
/**
604+
* Allows other features (like ItemHandler) to know if ItemESP will render
605+
* tracer lines in the current style configuration.
606+
*/
607+
public boolean rendersTracerLines()
608+
{
609+
return style.hasLines();
610+
}
611+
603612
private boolean isIgnored(ItemStack stack)
604613
{
605614
if(stack == null || stack.isEmpty())

src/main/java/net/wurstclient/hacks/itemhandler/ItemHandlerHack.java

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -723,14 +723,20 @@ public void onRender(PoseStack matrixStack, float partialTicks)
723723
{
724724
if(tracedItems.isEmpty())
725725
return;
726-
// Avoid duplicate rendering if ItemESP is enabled
726+
727727
net.wurstclient.hacks.ItemEspHack esp =
728728
net.wurstclient.WurstClient.INSTANCE.getHax().itemEspHack;
729-
if(esp != null && esp.isEnabled())
729+
boolean espEnabled = esp != null && esp.isEnabled();
730+
boolean espHasTracerLines = espEnabled && esp.rendersTracerLines();
731+
boolean shouldDrawBoxes = !espEnabled;
732+
boolean shouldDrawTracers = !espHasTracerLines;
733+
if(!shouldDrawBoxes && !shouldDrawTracers)
730734
return;
731735

732-
java.util.ArrayList<AABB> boxes = new java.util.ArrayList<>();
733-
java.util.ArrayList<Vec3> ends = new java.util.ArrayList<>();
736+
java.util.ArrayList<AABB> boxes =
737+
shouldDrawBoxes ? new java.util.ArrayList<>() : null;
738+
java.util.ArrayList<Vec3> ends =
739+
shouldDrawTracers ? new java.util.ArrayList<>() : null;
734740
for(GroundItem gi : trackedItems)
735741
{
736742
String baseId =
@@ -748,22 +754,27 @@ public void onRender(PoseStack matrixStack, float partialTicks)
748754
if(!traced)
749755
continue;
750756
Vec3 p = gi.position();
751-
boxes.add(new AABB(p.x - 0.18, p.y - 0.18, p.z - 0.18, p.x + 0.18,
752-
p.y + 0.18, p.z + 0.18));
753-
ends.add(p);
757+
if(shouldDrawBoxes)
758+
boxes.add(new AABB(p.x - 0.18, p.y - 0.18, p.z - 0.18,
759+
p.x + 0.18, p.y + 0.18, p.z + 0.18));
760+
if(shouldDrawTracers)
761+
ends.add(p);
754762
}
755-
if(boxes.isEmpty() && ends.isEmpty())
763+
boolean hasBoxes = shouldDrawBoxes && boxes != null && !boxes.isEmpty();
764+
boolean hasTracers =
765+
shouldDrawTracers && ends != null && !ends.isEmpty();
766+
if(!hasBoxes && !hasTracers)
756767
return;
757768
float[] rf = RenderUtils.getRainbowColor();
758769
int traceLines = RenderUtils.toIntColor(rf, 0.5f);
759770
int traceQuads = RenderUtils.toIntColor(rf, 0.35f);
760-
if(!boxes.isEmpty())
771+
if(hasBoxes)
761772
{
762773
RenderUtils.drawSolidBoxes(matrixStack, boxes, traceQuads, false);
763774
RenderUtils.drawOutlinedBoxes(matrixStack, boxes, traceLines,
764775
false);
765776
}
766-
if(!ends.isEmpty())
777+
if(hasTracers)
767778
RenderUtils.drawTracers(matrixStack, partialTicks, ends, traceLines,
768779
false);
769780
}

0 commit comments

Comments
 (0)