Skip to content

Commit ff61e43

Browse files
committed
ItemESP and Search Counters
1 parent 914640f commit ff61e43

File tree

2 files changed

+48
-4
lines changed

2 files changed

+48
-4
lines changed

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,18 @@ private enum SpecialMode
108108
new CheckboxSetting("Highlight frames with special",
109109
"Also highlight item frames if the item inside is special.", true);
110110

111+
// New: optionally show detected count in HackList
112+
private final CheckboxSetting showCountInHackList = new CheckboxSetting(
113+
"HackList count",
114+
"Appends the number of detected items to this hack's entry in the HackList.",
115+
false);
116+
111117
private final ArrayList<ItemEntity> items = new ArrayList<>();
112118
// cache for LIST mode: exact IDs and keyword terms
113119
private java.util.Set<String> specialExactIds;
114120
private String[] specialKeywords;
115121
private int lastSpecialListHash;
122+
private int foundCount; // current number of detected items
116123

117124
public ItemEspHack()
118125
{
@@ -132,6 +139,8 @@ public ItemEspHack()
132139
addSetting(linesOnlyForSpecial);
133140
addSetting(includeEquippedSpecial);
134141
addSetting(includeItemFrames);
142+
// new setting
143+
addSetting(showCountInHackList);
135144
}
136145

137146
@Override
@@ -148,6 +157,8 @@ protected void onDisable()
148157
EVENTS.remove(UpdateListener.class, this);
149158
EVENTS.remove(CameraTransformViewBobbingListener.class, this);
150159
EVENTS.remove(RenderListener.class, this);
160+
// reset count
161+
foundCount = 0;
151162
}
152163

153164
@Override
@@ -157,6 +168,8 @@ public void onUpdate()
157168
for(Entity entity : MC.world.getEntities())
158169
if(entity instanceof ItemEntity)
159170
items.add((ItemEntity)entity);
171+
// update count for HUD (clamped to 999)
172+
foundCount = Math.min(items.size(), 999);
160173
}
161174

162175
@Override
@@ -469,4 +482,13 @@ private Box smallBoxAt(Vec3d c)
469482
double r = 0.18;
470483
return new Box(c.x - r, c.y - r, c.z - r, c.x + r, c.y + r, c.z + r);
471484
}
485+
486+
@Override
487+
public String getRenderName()
488+
{
489+
String base = getName();
490+
if(showCountInHackList.isChecked() && foundCount > 0)
491+
return base + " [" + foundCount + "]";
492+
return base;
493+
}
472494
}

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

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ private enum SearchMode
8585
private final net.wurstclient.settings.ColorSetting fixedColor =
8686
new net.wurstclient.settings.ColorSetting("Fixed color",
8787
"Color used when \"Use fixed color\" is enabled.", Color.RED);
88+
// New: optionally show detected count in HackList
89+
private final net.wurstclient.settings.CheckboxSetting showCountInHackList =
90+
new net.wurstclient.settings.CheckboxSetting("HackList count",
91+
"Appends the number of found blocks to this hack's entry in the HackList.",
92+
false);
8893
private Block lastBlock;
8994
private String lastQuery = "";
9095
private ChunkAreaSetting.ChunkArea lastAreaSelection;
@@ -124,6 +129,8 @@ private enum SearchMode
124129
private java.util.Set<String> listExactIds;
125130
private String[] listKeywords;
126131

132+
private int foundCount; // number of currently displayed matches (clamped)
133+
127134
public SearchHack()
128135
{
129136
super("Search");
@@ -138,29 +145,38 @@ public SearchHack()
138145
addSetting(fixedColor);
139146
addSetting(area);
140147
addSetting(limit);
148+
// new setting
149+
addSetting(showCountInHackList);
141150
}
142151

143152
@Override
144153
public String getRenderName()
145154
{
146155
String colorMode = useFixedColor.isChecked() ? "Fixed" : "Rainbow";
156+
String base;
147157
switch(mode.getSelected())
148158
{
149159
case LIST:
150-
return getName() + " [List:" + blockList.size() + "] (" + colorMode
160+
base = getName() + " [List:" + blockList.size() + "] (" + colorMode
151161
+ ")";
162+
break;
152163
case QUERY:
153164
String rawQuery = query.getValue().trim();
154165
if(!rawQuery.isEmpty())
155-
return getName() + " [" + abbreviate(rawQuery) + "] ("
166+
base = getName() + " [" + abbreviate(rawQuery) + "] ("
156167
+ colorMode + ")";
157-
return getName() + " [query] (" + colorMode + ")";
168+
else
169+
base = getName() + " [query] (" + colorMode + ")";
170+
break;
158171
case BLOCK_ID:
159172
default:
160-
return getName() + " ["
173+
base = getName() + " ["
161174
+ block.getBlockName().replace("minecraft:", "") + "] ("
162175
+ colorMode + ")";
163176
}
177+
if(showCountInHackList.isChecked() && foundCount > 0)
178+
return base + " [" + Math.min(foundCount, 999) + "]";
179+
return base;
164180
}
165181

166182
@Override
@@ -198,6 +214,7 @@ protected void onDisable()
198214
lastMatchingBlocks = null;
199215
tracerEnds = null;
200216
lastPlayerChunk = null;
217+
foundCount = 0; // reset count
201218
}
202219

203220
@Override
@@ -510,6 +527,11 @@ private void setBufferFromTask()
510527
.getCenter();
511528
return pos.toCenterPos();
512529
}).collect(java.util.stream.Collectors.toList());
530+
// update count for HUD (clamped to 999)
531+
foundCount = Math.min(lastMatchingBlocks.size(), 999);
532+
}else
533+
{
534+
foundCount = 0;
513535
}
514536
}
515537

0 commit comments

Comments
 (0)