1818import java .util .Set ;
1919import java .util .TreeMap ;
2020
21+ import net .minecraft .client .render .Camera ;
22+ import net .minecraft .client .render .RenderLayer ;
23+ import net .minecraft .util .hit .BlockHitResult ;
24+ import net .minecraft .util .hit .HitResult ;
25+ import net .minecraft .util .math .BlockPos ;
26+ import net .minecraft .util .math .Vec3d ;
27+ import net .minecraft .world .RaycastContext ;
2128import net .wurstclient .Category ;
2229import net .wurstclient .Feature ;
2330import net .wurstclient .WurstClient ;
2835import net .wurstclient .other_feature .OtfList ;
2936import net .wurstclient .other_feature .OtherFeature ;
3037import net .wurstclient .events .UpdateListener ;
38+ import net .wurstclient .WurstRenderLayers ;
3139
3240public final class NiceWurstModule
3341{
@@ -53,6 +61,10 @@ public final class NiceWurstModule
5361 "net.wurstclient.hacks.PortalEspHack" ,
5462 "net.wurstclient.hacks.SearchHack" ,
5563 "net.wurstclient.hacks.TridentEspHack" );
64+ private static final Set <String > ENTITY_OVERLAY_CALLERS =
65+ Set .of ("net.wurstclient.hacks.MobEspHack" );
66+ private static final Set <String > TRACER_VISIBILITY_EXCEPTIONS =
67+ Set .of ("net.wurstclient.hacks.WaypointsHack" );
5668
5769 private static boolean applied ;
5870
@@ -138,6 +150,9 @@ public static boolean enforceDepthTest(boolean originalDepthTest)
138150 if (originalDepthTest || !isActive ())
139151 return originalDepthTest ;
140152
153+ if (isEntityOverlayCall ())
154+ return originalDepthTest ;
155+
141156 for (StackTraceElement element : Thread .currentThread ().getStackTrace ())
142157 {
143158 if (DEPTH_TEST_CALLERS .contains (element .getClassName ()))
@@ -147,6 +162,99 @@ public static boolean enforceDepthTest(boolean originalDepthTest)
147162 return originalDepthTest ;
148163 }
149164
165+ public static RenderLayer .MultiPhase enforceDepthTest (
166+ RenderLayer .MultiPhase originalLayer )
167+ {
168+ if (!isActive () || originalLayer == null )
169+ return originalLayer ;
170+
171+ if (isEntityOverlayCall ())
172+ return originalLayer ;
173+
174+ if (originalLayer == WurstRenderLayers .ESP_QUADS )
175+ return WurstRenderLayers .QUADS ;
176+
177+ if (originalLayer == WurstRenderLayers .ESP_QUADS_NO_CULLING )
178+ return WurstRenderLayers .QUADS_NO_CULLING ;
179+
180+ if (originalLayer == WurstRenderLayers .ESP_LINES )
181+ return WurstRenderLayers .LINES ;
182+
183+ if (originalLayer == WurstRenderLayers .ESP_LINE_STRIP )
184+ return WurstRenderLayers .LINE_STRIP ;
185+
186+ return originalLayer ;
187+ }
188+
189+ public static boolean shouldEnforceTracerVisibility ()
190+ {
191+ if (!isActive ())
192+ return false ;
193+
194+ for (StackTraceElement element : Thread .currentThread ().getStackTrace ())
195+ {
196+ if (TRACER_VISIBILITY_EXCEPTIONS .contains (element .getClassName ()))
197+ return false ;
198+ }
199+
200+ return true ;
201+ }
202+
203+ public static boolean shouldRenderTarget (Vec3d target )
204+ {
205+ if (!isActive () || target == null )
206+ return true ;
207+
208+ if (WurstClient .MC .world == null || WurstClient .MC .player == null )
209+ return true ;
210+
211+ Camera camera = WurstClient .MC .gameRenderer .getCamera ();
212+ if (camera == null )
213+ return true ;
214+
215+ Vec3d from = camera .getPos ();
216+ if (from == null )
217+ return true ;
218+
219+ if (from .squaredDistanceTo (target ) < 1e-6 )
220+ return true ;
221+
222+ RaycastContext context =
223+ new RaycastContext (from , target , RaycastContext .ShapeType .COLLIDER ,
224+ RaycastContext .FluidHandling .NONE , WurstClient .MC .player );
225+ HitResult hit = WurstClient .MC .world .raycast (context );
226+ if (hit == null || hit .getType () == HitResult .Type .MISS )
227+ return true ;
228+
229+ if (hit .getType () != HitResult .Type .BLOCK )
230+ return true ;
231+
232+ BlockPos hitPos = ((BlockHitResult )hit ).getBlockPos ();
233+ BlockPos targetPos = BlockPos .ofFloored (target );
234+ if (hitPos .equals (targetPos ))
235+ return true ;
236+
237+ double targetDistSq = from .squaredDistanceTo (target );
238+ double hitDistSq = hit .getPos ().squaredDistanceTo (from );
239+ return hitDistSq >= targetDistSq - 1e-3 ;
240+ }
241+
242+ public static boolean shouldOverlayEntityShapes ()
243+ {
244+ return isActive () && isEntityOverlayCall ();
245+ }
246+
247+ private static boolean isEntityOverlayCall ()
248+ {
249+ for (StackTraceElement element : Thread .currentThread ().getStackTrace ())
250+ {
251+ if (ENTITY_OVERLAY_CALLERS .contains (element .getClassName ()))
252+ return true ;
253+ }
254+
255+ return false ;
256+ }
257+
150258 private static void filterHackList (HackList hackList )
151259 {
152260 TreeMap <String , Hack > hackMap = getHackMap (hackList );
0 commit comments