1111import java .util .stream .Collectors ;
1212import java .util .stream .Stream ;
1313import java .util .stream .StreamSupport ;
14+ import java .awt .Color ;
1415
1516import net .minecraft .client .util .math .MatrixStack ;
1617import net .minecraft .entity .LivingEntity ;
1718import net .minecraft .entity .player .PlayerEntity ;
1819import net .minecraft .util .math .Box ;
19- import net .minecraft .util .math .MathHelper ;
2020import net .minecraft .util .math .Vec3d ;
2121import net .wurstclient .Category ;
2222import net .wurstclient .SearchTags ;
2626import net .wurstclient .hack .Hack ;
2727import net .wurstclient .settings .EspBoxSizeSetting ;
2828import net .wurstclient .settings .EspStyleSetting ;
29+ import net .wurstclient .settings .CheckboxSetting ;
30+ import net .wurstclient .settings .ColorSetting ;
2931import net .wurstclient .settings .filterlists .EntityFilterList ;
3032import net .wurstclient .settings .filters .*;
3133import net .wurstclient .util .EntityUtils ;
@@ -43,6 +45,13 @@ public final class MobEspHack extends Hack implements UpdateListener,
4345 "\u00a7 lAccurate\u00a7 r mode shows the exact hitbox of each mob.\n "
4446 + "\u00a7 lFancy\u00a7 r 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}
0 commit comments