2424import net .minecraft .entity .Entity ;
2525import net .minecraft .entity .EntityType ;
2626import net .minecraft .entity .player .PlayerEntity ;
27+ import net .minecraft .util .hit .EntityHitResult ;
2728import net .minecraft .util .math .Box ;
2829import net .minecraft .util .math .MathHelper ;
2930import org .joml .Vector3d ;
@@ -43,6 +44,21 @@ public class ESP extends Module {
4344 .build ()
4445 );
4546
47+ public final Setting <Boolean > highlightTarget = sgGeneral .add (new BoolSetting .Builder ()
48+ .name ("highlight-target" )
49+ .description ("highlights the currently targeted entity differently" )
50+ .defaultValue (false )
51+ .build ()
52+ );
53+
54+ public final Setting <Boolean > targetHitbox = sgGeneral .add (new BoolSetting .Builder ()
55+ .name ("target-hitbox" )
56+ .description ("draw the hitbox of the target entity" )
57+ .defaultValue (true )
58+ .visible (highlightTarget ::get )
59+ .build ()
60+ );
61+
4662 public final Setting <Integer > outlineWidth = sgGeneral .add (new IntSetting .Builder ()
4763 .name ("outline-width" )
4864 .description ("The width of the shader outline." )
@@ -170,6 +186,22 @@ public class ESP extends Module {
170186 .build ()
171187 );
172188
189+ private final Setting <SettingColor > targetColor = sgColors .add (new ColorSetting .Builder ()
190+ .name ("target-color" )
191+ .description ("The target color." )
192+ .defaultValue (new SettingColor (200 , 200 , 200 , 255 ))
193+ .visible (highlightTarget ::get )
194+ .build ()
195+ );
196+
197+ private final Setting <SettingColor > targetHitboxColor = sgColors .add (new ColorSetting .Builder ()
198+ .name ("target-hitbox-color" )
199+ .description ("The target hitbox color." )
200+ .defaultValue (new SettingColor (100 , 200 , 200 , 255 ))
201+ .visible (() -> highlightTarget .get () && targetHitbox .get ())
202+ .build ()
203+ );
204+
173205 private final Color lineColor = new Color ();
174206 private final Color sideColor = new Color ();
175207 private final Color baseColor = new Color ();
@@ -192,10 +224,12 @@ private void onRender3D(Render3DEvent event) {
192224
193225 count = 0 ;
194226
195- for ( Entity entity : mc . world . getEntities ()) {
196- if (shouldSkip ( entity )) continue ;
227+ Entity target = null ;
228+ if (highlightTarget . get () && targetHitbox . get () && mc . crosshairTarget instanceof EntityHitResult hr ) target = hr . getEntity () ;
197229
198- if (mode .get () == Mode .Box || mode .get () == Mode .Wireframe ) drawBoundingBox (event , entity );
230+ for (Entity entity : mc .world .getEntities ()) {
231+ if (target != entity && shouldSkip (entity )) continue ;
232+ if (target == entity || mode .get () == Mode .Box || mode .get () == Mode .Wireframe ) drawBoundingBox (event , entity );
199233 count ++;
200234 }
201235 }
@@ -207,15 +241,23 @@ private void drawBoundingBox(Render3DEvent event, Entity entity) {
207241 sideColor .set (color ).a ((int ) (sideColor .a * fillOpacity .get ()));
208242 }
209243
210- if (mode .get () == Mode .Box ) {
244+ if (mode .get () == Mode .Wireframe ) {
245+ WireframeEntityRenderer .render (event , entity , 1 , sideColor , lineColor , shapeMode .get ());
246+ }
247+
248+ boolean target = drawAsTarget (entity );
249+
250+ if (mode .get () == Mode .Box || (targetHitbox .get () && target )) {
211251 double x = MathHelper .lerp (event .tickDelta , entity .lastRenderX , entity .getX ()) - entity .getX ();
212252 double y = MathHelper .lerp (event .tickDelta , entity .lastRenderY , entity .getY ()) - entity .getY ();
213253 double z = MathHelper .lerp (event .tickDelta , entity .lastRenderZ , entity .getZ ()) - entity .getZ ();
214254
255+ ShapeMode shape = shapeMode .get ();
256+ if (target && mode .get () != Mode .Box ) shape = ShapeMode .Lines ;
257+ if (target ) lineColor .set (targetHitboxColor .get ());
258+
215259 Box box = entity .getBoundingBox ();
216- event .renderer .box (x + box .minX , y + box .minY , z + box .minZ , x + box .maxX , y + box .maxY , z + box .maxZ , sideColor , lineColor , shapeMode .get (), 0 );
217- } else {
218- WireframeEntityRenderer .render (event , entity , 1 , sideColor , lineColor , shapeMode .get ());
260+ event .renderer .box (x + box .minX , y + box .minY , z + box .minZ , x + box .maxX , y + box .maxY , z + box .maxZ , sideColor , lineColor , shape , 0 );
219261 }
220262 }
221263
@@ -297,20 +339,33 @@ private boolean checkCorner(double x, double y, double z, Vector3d min, Vector3d
297339
298340 // Utils
299341
342+ public boolean drawAsTarget (Entity entity ) {
343+ return highlightTarget .get () && mc .crosshairTarget instanceof EntityHitResult hr && hr .getEntity () == entity ;
344+ }
345+
300346 public boolean shouldSkip (Entity entity ) {
347+ if (drawAsTarget (entity )) return false ;
301348 if (!entities .get ().contains (entity .getType ())) return true ;
302349 if (entity == mc .player && ignoreSelf .get ()) return true ;
303350 if (entity == mc .cameraEntity && mc .options .getPerspective ().isFirstPerson ()) return true ;
304351 return !EntityUtils .isInRenderDistance (entity );
305352 }
306353
307354 public Color getColor (Entity entity ) {
308- if (!entities .get ().contains (entity .getType ())) return null ;
355+ Color color ;
356+ double alpha = 1 ;
309357
310- double alpha = getFadeAlpha (entity );
311- if (alpha == 0 ) return null ;
358+ if (drawAsTarget (entity )) {
359+ color = targetColor .get ();
360+ } else {
361+ if (!entities .get ().contains (entity .getType ())) return null ;
362+
363+ alpha = getFadeAlpha (entity );
364+ if (alpha == 0 ) return null ;
365+
366+ color = getEntityTypeColor (entity );
367+ }
312368
313- Color color = getEntityTypeColor (entity );
314369 return baseColor .set (color .r , color .g , color .b , (int ) (color .a * alpha ));
315370 }
316371
0 commit comments