Skip to content

Commit fa800e1

Browse files
committed
Port 26.2 render projection fixes
1 parent f6fadfb commit fa800e1

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,8 @@ public void onRenderGUI(GuiGraphicsExtractor context, float partialTicks)
281281

282282
Vec3 worldPos = EntityUtils.getLerpedPos(entity, partialTicks)
283283
.add(0, entity.getBbHeight() + 0.35, 0);
284+
if(isBehindCamera(worldPos))
285+
continue;
284286
Vec3 projected = MC.gameRenderer.projectPointToScreen(worldPos);
285287
if(projected.z <= -1 || projected.z >= 1)
286288
continue;
@@ -333,6 +335,8 @@ public void onRenderGUI(GuiGraphicsExtractor context, float partialTicks)
333335
}
334336

335337
Vec3 worldPos = center.scale(1.0 / clusterSize);
338+
if(isBehindCamera(worldPos))
339+
continue;
336340
Vec3 projected = MC.gameRenderer.projectPointToScreen(worldPos);
337341
if(projected.z <= -1 || projected.z >= 1)
338342
continue;
@@ -370,6 +374,19 @@ private void drawItemTag(GuiGraphicsExtractor context, Font font,
370374
context.pose().popMatrix();
371375
}
372376

377+
private boolean isBehindCamera(Vec3 worldPos)
378+
{
379+
if(MC.gameRenderer == null || MC.gameRenderer.getMainCamera() == null)
380+
return false;
381+
382+
Vec3 camPos = RenderUtils.getCameraPos();
383+
Vec3 toItem = worldPos.subtract(camPos);
384+
if(toItem.lengthSqr() == 0)
385+
return false;
386+
387+
return toItem.dot(RenderUtils.getCameraRotation().toLookVec()) <= 0;
388+
}
389+
373390
// Expose ignored-items configuration for other features (like ItemHandler)
374391
public boolean shouldUseIgnoredItems()
375392
{

src/main/java/net/wurstclient/mixin/StorageMixin.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
2121
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
2222
import com.mojang.blaze3d.vertex.PoseStack;
23+
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
2324
import net.minecraft.client.renderer.SubmitNodeStorage;
2425
import net.minecraft.client.renderer.feature.NameTagFeatureRenderer;
2526
import net.minecraft.client.renderer.state.level.CameraRenderState;
@@ -48,6 +49,13 @@ private void wrapLabelScale(PoseStack matrices, float x, float y, float z,
4849
int i, Component text, boolean bl, int j, double d,
4950
CameraRenderState state)
5051
{
52+
if(WurstClient.MC != null
53+
&& WurstClient.MC.screen instanceof AbstractContainerScreen<?>)
54+
{
55+
original.call(matrices, x, y, z);
56+
return;
57+
}
58+
5159
NameTagsHack nameTags = WurstClient.INSTANCE.getHax().nameTagsHack;
5260
if(!nameTags.isEnabled())
5361
{

0 commit comments

Comments
 (0)