@@ -276,6 +276,8 @@ public void onRenderGUI(GuiGraphicsExtractor context, float partialTicks)
276276
277277 Vec3 worldPos = EntityUtils .getLerpedPos (entity , partialTicks )
278278 .add (0 , entity .getBbHeight () + 0.35 , 0 );
279+ if (isBehindCamera (worldPos ))
280+ continue ;
279281 Vec3 projected = MC .gameRenderer .projectPointToScreen (worldPos );
280282 if (projected .z <= -1 || projected .z >= 1 )
281283 continue ;
@@ -328,6 +330,8 @@ public void onRenderGUI(GuiGraphicsExtractor context, float partialTicks)
328330 }
329331
330332 Vec3 worldPos = center .scale (1.0 / clusterSize );
333+ if (isBehindCamera (worldPos ))
334+ continue ;
331335 Vec3 projected = MC .gameRenderer .projectPointToScreen (worldPos );
332336 if (projected .z <= -1 || projected .z >= 1 )
333337 continue ;
@@ -365,6 +369,23 @@ private void drawItemTag(GuiGraphicsExtractor context, Font font,
365369 context .pose ().popMatrix ();
366370 }
367371
372+ private boolean isBehindCamera (Vec3 worldPos )
373+ {
374+ if (MC .gameRenderer == null || MC .gameRenderer .mainCamera () == null )
375+ return false ;
376+
377+ Vec3 camPos = MC .gameRenderer .mainCamera ().position ();
378+ Vec3 toItem = worldPos .subtract (camPos );
379+ if (toItem .lengthSqr () == 0 )
380+ return false ;
381+
382+ double yawRad = Math .toRadians (MC .gameRenderer .mainCamera ().yRot ());
383+ double pitchRad = Math .toRadians (MC .gameRenderer .mainCamera ().xRot ());
384+ Vec3 forward = new Vec3 (-Math .sin (yawRad ) * Math .cos (pitchRad ),
385+ -Math .sin (pitchRad ), Math .cos (yawRad ) * Math .cos (pitchRad ));
386+ return toItem .dot (forward ) <= 0 ;
387+ }
388+
368389 // Expose ignored-items configuration for other features (like ItemHandler)
369390 public boolean shouldUseIgnoredItems ()
370391 {
0 commit comments