Skip to content

Commit 14088f1

Browse files
committed
Improved Sky rendering under water
1 parent 10d8c6b commit 14088f1

File tree

5 files changed

+45
-3
lines changed

5 files changed

+45
-3
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package simpleclient.mixin.performance;
2+
3+
import com.mojang.blaze3d.vertex.PoseStack;
4+
import net.minecraft.client.Camera;
5+
import net.minecraft.client.renderer.LevelRenderer;
6+
import net.minecraft.world.level.material.FogType;
7+
import org.joml.Matrix4f;
8+
import org.spongepowered.asm.mixin.Mixin;
9+
import org.spongepowered.asm.mixin.injection.At;
10+
import org.spongepowered.asm.mixin.injection.Inject;
11+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
12+
import simpleclient.feature.PerformanceBoost;
13+
14+
@Mixin(LevelRenderer.class)
15+
public class LevelRendererMixin {
16+
// +10% FPS under water
17+
@Inject(at = @At("HEAD"), method = "renderSky", cancellable = true)
18+
private void renderSky(PoseStack poseStack, Matrix4f matrix4f, float tickDelta, Camera camera, boolean bl, Runnable runnable, CallbackInfo ci) {
19+
if (PerformanceBoost.ENABLED && camera.getFluidInCamera() != FogType.WATER) ci.cancel();
20+
}
21+
}

simpleclient-1.19.4/src/main/java/simpleclient/mixin/performance/SharedConstantsMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ public class SharedConstantsMixin {
1212
// Faster starting
1313
@Inject(at = @At("HEAD"), method = "enableDataFixerOptimizations", cancellable = true)
1414
private static void enableDataFixerOptimizations(CallbackInfo ci) {
15-
if (PerformanceBoost.INSTANCE.isEnabled()) ci.cancel();
15+
if (PerformanceBoost.ENABLED) ci.cancel();
1616
}
1717
}

simpleclient-1.19.4/src/main/resources/simpleclient.mixins.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
],
88
"client": [
99
"GuiMixin",
10-
"performance.CubeMixin",
10+
"performance.LevelRendererMixin",
1111
"performance.SharedConstantsMixin"
1212
],
1313
"injectors": {
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package simpleclient.mixin.performance;
2+
3+
import com.mojang.blaze3d.vertex.PoseStack;
4+
import net.minecraft.client.Camera;
5+
import net.minecraft.client.renderer.LevelRenderer;
6+
import net.minecraft.world.level.material.FogType;
7+
import org.joml.Matrix4f;
8+
import org.spongepowered.asm.mixin.Mixin;
9+
import org.spongepowered.asm.mixin.injection.At;
10+
import org.spongepowered.asm.mixin.injection.Inject;
11+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
12+
import simpleclient.feature.PerformanceBoost;
13+
14+
@Mixin(LevelRenderer.class)
15+
public class LevelRendererMixin {
16+
// +10% FPS under water
17+
@Inject(at = @At("HEAD"), method = "renderSky", cancellable = true)
18+
private void renderSky(PoseStack poseStack, Matrix4f matrix4f, float tickDelta, Camera camera, boolean bl, Runnable runnable, CallbackInfo ci) {
19+
if (PerformanceBoost.ENABLED && camera.getFluidInCamera() != FogType.NONE) ci.cancel();
20+
}
21+
}

simpleclient-1.20/src/main/resources/simpleclient.mixins.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
],
88
"client": [
99
"GuiMixin",
10-
"performance.CubeMixin",
10+
"performance.LevelRendererMixin",
1111
"performance.SharedConstantsMixin"
1212
],
1313
"injectors": {

0 commit comments

Comments
 (0)