Skip to content

Commit 9d81e6d

Browse files
committed
Fixed 26.2 Bugs
1 parent 5ddd6f1 commit 9d81e6d

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

src/main/java/net/wurstclient/hacks/ItemEspHack.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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
{

src/main/java/net/wurstclient/mixin/nametags/SubmitNodeCollectionMixin.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
2020
import com.mojang.blaze3d.vertex.PoseStack;
2121

22+
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
2223
import net.minecraft.client.gui.Font;
2324
import net.minecraft.client.renderer.SubmitNodeCollection;
2425
import net.minecraft.client.renderer.feature.NameTagFeatureRenderer;
@@ -52,6 +53,13 @@ private void wrapLabelScale(PoseStack matrices, float x, float y, float z,
5253
@Nullable Vec3 nameTagAttachment, int offset, Component name,
5354
boolean seeThrough, int lightCoords, CameraRenderState camera)
5455
{
56+
if(WurstClient.MC != null && WurstClient.MC.gui
57+
.screen() instanceof AbstractContainerScreen<?>)
58+
{
59+
original.call(matrices, x, y, z);
60+
return;
61+
}
62+
5563
NameTagsHack nameTagsHack = WurstClient.INSTANCE.getHax().nameTagsHack;
5664
if(!nameTagsHack.isEnabled())
5765
{

0 commit comments

Comments
 (0)