2121import net .minecraft .registry .Registries ;
2222import net .minecraft .util .Identifier ;
2323import net .minecraft .util .math .Box ;
24- import net .minecraft .util .math .Vec3d ;
2524import net .wurstclient .Category ;
2625import net .wurstclient .SearchTags ;
2726import net .wurstclient .events .CameraTransformViewBobbingListener ;
3130import net .wurstclient .settings .CheckboxSetting ;
3231import net .wurstclient .settings .ColorSetting ;
3332import net .wurstclient .settings .EspBoxSizeSetting ;
34- import net .wurstclient .settings .EspStyleSetting ;
3533import net .wurstclient .settings .TextFieldSetting ;
3634import net .wurstclient .util .EntityUtils ;
3735import net .wurstclient .util .RenderUtils ;
@@ -56,10 +54,14 @@ private enum SearchMode
5654 private final net .wurstclient .settings .EntityTypeListSetting entityList =
5755 new net .wurstclient .settings .EntityTypeListSetting ("Entity List" ,
5856 "Entities to match when Mode is set to List." );
59- private final EspStyleSetting style = new EspStyleSetting ();
60- private final EspBoxSizeSetting boxSize = new EspBoxSizeSetting (
57+ private final MobSearchStyleSetting style = new MobSearchStyleSetting ();
58+ private final EspBoxSizeSetting boxSize = new EspBoxSizeSetting ("Box size" ,
6159 "\u00a7 lAccurate\u00a7 r mode shows the exact hitbox of each mob.\n "
62- + "\u00a7 lFancy\u00a7 r mode shows slightly larger boxes that look better." );
60+ + "\u00a7 lFancy\u00a7 r mode shows slightly larger boxes that look better." ,
61+ EspBoxSizeSetting .BoxSize .ACCURATE );
62+
63+ private final CheckboxSetting fillShapes = new CheckboxSetting (
64+ "Fill shapes" , "Render filled versions of the ESP shapes." , true );
6365 private final TextFieldSetting typeId = new TextFieldSetting ("Type" ,
6466 "The entity type to match when Query is empty (e.g. minecraft:zombie or zombie)." ,
6567 "minecraft:zombie" , v -> v .length () <= MAX_TEXT_LENGTH );
@@ -70,7 +72,7 @@ private enum SearchMode
7072 new CheckboxSetting ("Rainbow colors" ,
7173 "Use a rainbow color instead of the fixed color." , false );
7274 private final ColorSetting color = new ColorSetting ("Color" ,
73- "Fixed color used when Rainbow colors is disabled." , Color .RED );
75+ "Fixed color used when Rainbow colors is disabled." , Color .PINK );
7476
7577 private final ArrayList <LivingEntity > matches = new ArrayList <>();
7678 private SearchMode lastMode ;
@@ -87,6 +89,7 @@ public MobSearchHack()
8789 addSetting (entityList );
8890 addSetting (style );
8991 addSetting (boxSize );
92+ addSetting (fillShapes );
9093 addSetting (typeId );
9194 addSetting (query );
9295 addSetting (useRainbow );
@@ -220,31 +223,76 @@ public void onRender(MatrixStack matrixStack, float partialTicks)
220223 {
221224 if (matches .isEmpty ())
222225 return ;
223- int colorI = getColorI (0.5F );
224226
225- if (style .hasBoxes ())
227+ MobSearchStyleSetting .Shape shape = style .getShape ();
228+ boolean drawShape = shape != MobSearchStyleSetting .Shape .NONE ;
229+ boolean drawLines = style .hasLines ();
230+ boolean drawFill = drawShape && fillShapes .isChecked ();
231+
232+ ArrayList <ColoredBox > outlineShapes =
233+ drawShape ? new ArrayList <>(matches .size ()) : null ;
234+ ArrayList <ColoredBox > filledShapes =
235+ drawFill ? new ArrayList <>(matches .size ()) : null ;
236+ ArrayList <ColoredPoint > ends =
237+ drawLines ? new ArrayList <>(matches .size ()) : null ;
238+
239+ if (drawShape || drawLines )
226240 {
227- double extra = boxSize .getExtraSize () / 2 ;
228- ArrayList < ColoredBox > boxes = new ArrayList <>( matches . size ());
241+ double extra = drawShape ? boxSize .getExtraSize () / 2D : 0 ;
242+
229243 for (LivingEntity e : matches )
230244 {
231- Box box = EntityUtils .getLerpedBox (e , partialTicks )
232- .offset (0 , extra , 0 ).expand (extra );
233- boxes .add (new ColoredBox (box , colorI ));
245+ Box lerpedBox = EntityUtils .getLerpedBox (e , partialTicks );
246+ int outlineColor = getColorI (0.5F );
247+
248+ if (drawShape )
249+ {
250+ Box box = lerpedBox .offset (0 , extra , 0 ).expand (extra );
251+ outlineShapes .add (new ColoredBox (box , outlineColor ));
252+
253+ if (filledShapes != null )
254+ {
255+ int fillColor = getColorI (0.15F );
256+ filledShapes .add (new ColoredBox (box , fillColor ));
257+ }
258+ }
259+
260+ if (drawLines && ends != null )
261+ ends .add (
262+ new ColoredPoint (lerpedBox .getCenter (), outlineColor ));
234263 }
235- RenderUtils .drawOutlinedBoxes (matrixStack , boxes , false );
236264 }
237265
238- if (style . hasLines ())
266+ if (filledShapes != null && ! filledShapes . isEmpty ())
239267 {
240- ArrayList <ColoredPoint > ends = new ArrayList <>(matches .size ());
241- for (LivingEntity e : matches )
268+ switch (shape )
242269 {
243- Vec3d p = EntityUtils .getLerpedBox (e , partialTicks ).getCenter ();
244- ends .add (new ColoredPoint (p , colorI ));
270+ case BOX -> RenderUtils .drawSolidBoxes (matrixStack ,
271+ filledShapes , false );
272+ case OCTAHEDRON -> RenderUtils .drawSolidOctahedrons (matrixStack ,
273+ filledShapes , false );
274+ default ->
275+ {
276+ }
245277 }
246- RenderUtils .drawTracers (matrixStack , partialTicks , ends , false );
247278 }
279+
280+ if (outlineShapes != null && !outlineShapes .isEmpty ())
281+ {
282+ switch (shape )
283+ {
284+ case BOX -> RenderUtils .drawOutlinedBoxes (matrixStack ,
285+ outlineShapes , false );
286+ case OCTAHEDRON -> RenderUtils
287+ .drawOutlinedOctahedrons (matrixStack , outlineShapes , false );
288+ default ->
289+ {
290+ }
291+ }
292+ }
293+
294+ if (ends != null && !ends .isEmpty ())
295+ RenderUtils .drawTracers (matrixStack , partialTicks , ends , false );
248296 }
249297
250298 private int getColorI (float alpha )
@@ -311,4 +359,58 @@ private String abbreviate(String text)
311359 return text ;
312360 return text .substring (0 , 32 ) + "..." ;
313361 }
362+
363+ // Local style setting that mirrors MobEsp's style but for MobSearch
364+ private static final class MobSearchStyleSetting extends
365+ net .wurstclient .settings .EnumSetting <MobSearchStyleSetting .Style >
366+ {
367+ private MobSearchStyleSetting ()
368+ {
369+ super ("Style" , Style .values (), Style .OCTAHEDRONS );
370+ }
371+
372+ public Shape getShape ()
373+ {
374+ return getSelected ().shape ;
375+ }
376+
377+ public boolean hasLines ()
378+ {
379+ return getSelected ().lines ;
380+ }
381+
382+ enum Shape
383+ {
384+ NONE ,
385+ BOX ,
386+ OCTAHEDRON ;
387+ }
388+
389+ private enum Style
390+ {
391+ BOXES ("Boxes only" , Shape .BOX , false ),
392+ OCTAHEDRONS ("Octahedrons only" , Shape .OCTAHEDRON , false ),
393+ LINES ("Lines only" , Shape .NONE , true ),
394+ LINES_AND_BOXES ("Lines and boxes" , Shape .BOX , true ),
395+ LINES_AND_OCTAHEDRONS ("Lines and octahedrons" , Shape .OCTAHEDRON ,
396+ true );
397+
398+ private final String name ;
399+ private final Shape shape ;
400+ private final boolean lines ;
401+
402+ private Style (String name , Shape shape , boolean lines )
403+ {
404+ this .name = name ;
405+ this .shape = shape ;
406+ this .lines = lines ;
407+ }
408+
409+ @ Override
410+ public String toString ()
411+ {
412+ return name ;
413+ }
414+ }
415+ }
314416}
0 commit comments