Skip to content

Commit 10cb7db

Browse files
committed
MobESP: add rainbow/fixed color options; Search: multi-term query; polish README notes; UI: sticky area + tracers updates
1 parent f9d084b commit 10cb7db

File tree

3 files changed

+51
-20
lines changed

3 files changed

+51
-20
lines changed

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

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
import java.util.stream.Collectors;
1212
import java.util.stream.Stream;
1313
import java.util.stream.StreamSupport;
14+
import java.awt.Color;
1415

1516
import net.minecraft.client.util.math.MatrixStack;
1617
import net.minecraft.entity.LivingEntity;
1718
import net.minecraft.entity.player.PlayerEntity;
1819
import net.minecraft.util.math.Box;
19-
import net.minecraft.util.math.MathHelper;
2020
import net.minecraft.util.math.Vec3d;
2121
import net.wurstclient.Category;
2222
import net.wurstclient.SearchTags;
@@ -26,6 +26,8 @@
2626
import net.wurstclient.hack.Hack;
2727
import net.wurstclient.settings.EspBoxSizeSetting;
2828
import net.wurstclient.settings.EspStyleSetting;
29+
import net.wurstclient.settings.CheckboxSetting;
30+
import net.wurstclient.settings.ColorSetting;
2931
import net.wurstclient.settings.filterlists.EntityFilterList;
3032
import net.wurstclient.settings.filters.*;
3133
import net.wurstclient.util.EntityUtils;
@@ -43,6 +45,13 @@ public final class MobEspHack extends Hack implements UpdateListener,
4345
"\u00a7lAccurate\u00a7r mode shows the exact hitbox of each mob.\n"
4446
+ "\u00a7lFancy\u00a7r mode shows slightly larger boxes that look better.");
4547

48+
// New color options to match MobSearch
49+
private final CheckboxSetting useRainbow =
50+
new CheckboxSetting("Rainbow colors",
51+
"Use a rainbow color instead of the fixed color.", false);
52+
private final ColorSetting color = new ColorSetting("Color",
53+
"Fixed color used when Rainbow colors is disabled.", Color.RED);
54+
4655
private final EntityFilterList entityFilters =
4756
new EntityFilterList(FilterHostileSetting.genericVision(false),
4857
FilterNeutralSetting
@@ -75,6 +84,9 @@ public MobEspHack()
7584
setCategory(Category.RENDER);
7685
addSetting(style);
7786
addSetting(boxSize);
87+
// Add new color settings
88+
addSetting(useRainbow);
89+
addSetting(color);
7890
entityFilters.forEach(this::addSetting);
7991
}
8092

@@ -130,7 +142,7 @@ public void onRender(MatrixStack matrixStack, float partialTicks)
130142
{
131143
Box box = EntityUtils.getLerpedBox(e, partialTicks)
132144
.offset(0, extraSize, 0).expand(extraSize);
133-
boxes.add(new ColoredBox(box, getColor(e)));
145+
boxes.add(new ColoredBox(box, getColorI(0.5F)));
134146
}
135147

136148
RenderUtils.drawOutlinedBoxes(matrixStack, boxes, false);
@@ -143,19 +155,20 @@ public void onRender(MatrixStack matrixStack, float partialTicks)
143155
{
144156
Vec3d point =
145157
EntityUtils.getLerpedBox(e, partialTicks).getCenter();
146-
ends.add(new ColoredPoint(point, getColor(e)));
158+
ends.add(new ColoredPoint(point, getColorI(0.5F)));
147159
}
148160

149161
RenderUtils.drawTracers(matrixStack, partialTicks, ends, false);
150162
}
151163
}
152164

153-
private int getColor(LivingEntity e)
165+
private int getColorI(float alpha)
154166
{
155-
float f = MC.player.distanceTo(e) / 20F;
156-
float r = MathHelper.clamp(2 - f, 0, 1);
157-
float g = MathHelper.clamp(f, 0, 1);
158-
float[] rgb = {r, g, 0};
159-
return RenderUtils.toIntColor(rgb, 0.5F);
167+
if(useRainbow.isChecked())
168+
{
169+
float[] rgb = RenderUtils.getRainbowColor();
170+
return RenderUtils.toIntColor(rgb, alpha);
171+
}
172+
return RenderUtils.toIntColor(color.getColorF(), alpha);
160173
}
161174
}

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ private Predicate<LivingEntity> byExactType(String normalizedType)
181181

182182
private Predicate<LivingEntity> byFuzzyQuery(String q)
183183
{
184+
// Support multiple comma-separated terms, match if any term matches
185+
String[] terms = Stream.of(q.split(",")).map(String::trim)
186+
.filter(s -> !s.isEmpty()).toArray(String[]::new);
184187
return e -> {
185188
Identifier id = Registries.ENTITY_TYPE.getId(e.getType());
186189
String s = id == null ? "" : id.toString();
@@ -189,10 +192,14 @@ private Predicate<LivingEntity> byFuzzyQuery(String q)
189192
String localSpaced = local.replace('_', ' ');
190193
String transKey = e.getType().getTranslationKey();
191194
String display = e.getType().getName().getString();
192-
return containsNormalized(s, q) || containsNormalized(local, q)
193-
|| containsNormalized(localSpaced, q)
194-
|| containsNormalized(transKey, q)
195-
|| containsNormalized(display, q);
195+
for(String term : terms)
196+
if(containsNormalized(s, term)
197+
|| containsNormalized(local, term)
198+
|| containsNormalized(localSpaced, term)
199+
|| containsNormalized(transKey, term)
200+
|| containsNormalized(display, term))
201+
return true;
202+
return false;
196203
};
197204
}
198205

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

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import java.util.Comparator;
1313
import java.util.HashSet;
1414
import java.util.Locale;
15+
import java.util.Arrays;
1516
import java.util.concurrent.ForkJoinPool;
1617
import java.util.concurrent.ForkJoinTask;
1718
import java.util.stream.Collectors;
@@ -75,7 +76,8 @@ public final class SearchHack extends Hack implements UpdateListener,
7576

7677
private final ChunkAreaSetting area = new ChunkAreaSetting("Area",
7778
"The area around the player to search in.\n"
78-
+ "Higher values require a faster computer.");
79+
+ "Higher values require a faster computer.",
80+
ChunkAreaSetting.ChunkArea.A33);
7981

8082
private final SliderSetting limit = new SliderSetting("Limit",
8183
"The maximum number of blocks to display.\n"
@@ -313,12 +315,21 @@ private boolean blockMatchesQuery(Block block, String normalizedQuery)
313315
String id = BlockUtils.getName(block);
314316
String localId =
315317
id.contains(":") ? id.substring(id.indexOf(":") + 1) : id;
316-
317-
return containsNormalized(id, normalizedQuery)
318-
|| containsNormalized(localId, normalizedQuery)
319-
|| containsNormalized(localId.replace('_', ' '), normalizedQuery)
320-
|| containsNormalized(block.getTranslationKey(), normalizedQuery)
321-
|| containsNormalized(block.getName().getString(), normalizedQuery);
318+
// Support multiple comma-separated terms; match if ANY term matches
319+
String[] terms = Arrays.stream(normalizedQuery.split(","))
320+
.map(String::trim).filter(s -> !s.isEmpty()).toArray(String[]::new);
321+
if(terms.length == 0)
322+
terms = new String[]{normalizedQuery};
323+
String localSpaced = localId.replace('_', ' ');
324+
String transKey = block.getTranslationKey();
325+
String display = block.getName().getString();
326+
for(String term : terms)
327+
if(containsNormalized(id, term) || containsNormalized(localId, term)
328+
|| containsNormalized(localSpaced, term)
329+
|| containsNormalized(transKey, term)
330+
|| containsNormalized(display, term))
331+
return true;
332+
return false;
322333
}
323334

324335
private boolean containsNormalized(String haystack, String normalizedQuery)

0 commit comments

Comments
 (0)