Skip to content

Commit 3442f63

Browse files
committed
Avoid zero-alpha and treat near-opaque XRay/SurfaceXray as opaque to prevent Sodium translucent BSP crashes
1 parent 4116e27 commit 3442f63

File tree

5 files changed

+36
-5
lines changed

5 files changed

+36
-5
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,12 @@ Because so many of these mods are entirely original, I plan to release some of t
316316
- Reconnect to server and immediately send a command, such as /op player
317317
- Adds mixin buttons to disconnect/kick/ban screens for all cracked/offline servers that have the above functions
318318

319+
### CoordLogger
320+
- Detect world and local events and attempt to position it with ESP and chat messages
321+
- Events that are too far away the direction will be given
322+
- Toggles for various types of events
323+
- Toggles for debugging and ESP
324+
319325
## What’s changed or improved in this fork?
320326

321327
### ItemESP (Expanded)
@@ -373,6 +379,7 @@ Examples:
373379
![Search](https://i.imgur.com/jxcn89u.png)
374380

375381
### X-Ray Improvements
382+
- Prevent zero-alpha and treat near-opaque as opaque to prevent Sodium translucent BSP crashes
376383
- Added ESP (Highlight Corners and or Fill Blocks)
377384
- Uses cached positions for speed
378385
- Optional transparency slider for ESP

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,9 @@ public int getSurfaceOpacityMask()
256256
{
257257
int alpha = Math.max(0,
258258
Math.min(255, (int)Math.round(getSurfaceOpacity() * 255)));
259+
if(alpha == 0)
260+
alpha = 1; // avoid fully-zero alpha mask which can trigger renderer
261+
// edge-cases
259262
return alpha << 24 | 0x00FFFFFF;
260263
}
261264

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,12 @@ public boolean isOpacityMode()
606606

607607
public int getOpacityColorMask()
608608
{
609-
return (int)(opacity.getValue() * 255) << 24 | 0xFFFFFF;
609+
int a = Math.max(0,
610+
Math.min(255, (int)Math.round(opacity.getValue() * 255)));
611+
if(a == 0)
612+
a = 1; // avoid fully-zero alpha which can trigger renderer
613+
// edge-cases
614+
return (a << 24) | 0x00FFFFFF;
610615
}
611616

612617
public float getOpacityFloat()

src/main/java/net/wurstclient/mixin/sodium/BlockRendererMixin.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,24 @@ private int onBufferQuad(int original)
4343
{
4444
SurfaceState surfaceState = surface.classifyBlock(state, pos);
4545
if(surfaceState == SurfaceState.INTERIOR)
46-
return original & 0x00FFFFFF;
46+
return original & 0x01FFFFFF;
4747
if(surfaceState == SurfaceState.SURFACE)
48+
{
49+
float surf = surface.getSurfaceOpacity();
50+
if(surf >= 0.99f)
51+
return original; // treat almost-opaque as opaque to avoid
52+
// translucent sorting
4853
original &= surface.getSurfaceOpacityMask();
54+
}
4955
}
5056

5157
XRayHack xray = WurstClient.INSTANCE.getHax().xRayHack;
5258
if(!xray.isOpacityMode() || xray.isVisible(state.getBlock(), pos))
5359
return original;
54-
60+
float op = xray.getOpacityFloat();
61+
if(op >= 0.99f)
62+
return original; // avoid sending quads to Sodium translucent
63+
// pipeline
5564
return original & xray.getOpacityColorMask();
5665
}
5766
}

src/main/java/net/wurstclient/mixin/sodium/DefaultFluidRendererMixin.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,23 @@ private int onUpdateQuad(int original, @Local(argsOnly = true) BlockPos pos,
103103
{
104104
SurfaceState surfaceState = surface.classifyFluid(fluid, pos);
105105
if(surfaceState == SurfaceState.INTERIOR)
106-
return original & 0x00FFFFFF;
106+
return original & 0x01FFFFFF;
107107
if(surfaceState == SurfaceState.SURFACE)
108+
{
109+
float surf = surface.getSurfaceOpacity();
110+
if(surf >= 0.99f)
111+
return original;
108112
original &= surface.getSurfaceOpacityMask();
113+
}
109114
}
110115

111116
XRayHack xray = WurstClient.INSTANCE.getHax().xRayHack;
112117
if(!xray.isOpacityMode()
113118
|| xray.isVisible(fluid.createLegacyBlock().getBlock(), pos))
114119
return original;
115-
120+
float op = xray.getOpacityFloat();
121+
if(op >= 0.99f)
122+
return original;
116123
return original & xray.getOpacityColorMask();
117124
}
118125
}

0 commit comments

Comments
 (0)