Skip to content

Commit d11cc92

Browse files
committed
Added option for disabling cloud rendering
1 parent 14088f1 commit d11cc92

File tree

12 files changed

+104
-16
lines changed

12 files changed

+104
-16
lines changed
Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,37 @@
11
package simpleclient.feature;
22

3+
import com.google.gson.JsonObject;
4+
import net.minecraft.network.chat.Component;
5+
import simpleclient.feature.config.EnableConfigEntry;
6+
37
public class PerformanceBoost extends EnableableFeature {
4-
public static PerformanceBoost INSTANCE = new PerformanceBoost();
5-
public static boolean ENABLED = INSTANCE.isEnabled();
8+
public static boolean ENABLED = false;
9+
public static boolean FASTBOOT = false;
10+
public static boolean DONT_RENDER_CLOUDS = false;
11+
public static boolean DONT_RENDER_SKY_UNDER_WATER = false;
12+
private final EnableConfigEntry fastBoot = new EnableConfigEntry("fastboot", Component.translatable("simpleclient.performance.fastboot"), true);
13+
private final EnableConfigEntry dontRenderCouds = new EnableConfigEntry("dont_render_clouds", Component.translatable("simpleclient.performance.dont_render_clouds"), true);
14+
private final EnableConfigEntry dontRenderSkyUnderWater = new EnableConfigEntry("dont_render_sky_under_water", Component.translatable("simpleclient.performance.dont_render_sky_under_water"), true);
15+
616
public PerformanceBoost() {
717
super(FeatureType.PERFORMANCE_BOOST);
18+
addConfigEntry(fastBoot);
19+
addConfigEntry(dontRenderCouds);
20+
addConfigEntry(dontRenderSkyUnderWater);
21+
refresh();
22+
}
23+
24+
public void refresh() {
25+
ENABLED = isEnabled();
26+
JsonObject data = getData();
27+
FASTBOOT = ENABLED && fastBoot.load(data);
28+
DONT_RENDER_CLOUDS = ENABLED && dontRenderCouds.load(data);
29+
DONT_RENDER_SKY_UNDER_WATER = ENABLED && dontRenderSkyUnderWater.load(data);
830
}
931

1032
@Override
11-
public void setEnabled(boolean enabled) {
12-
super.setEnabled(enabled);
13-
ENABLED = enabled;
33+
public void setData(JsonObject data) {
34+
super.setData(data);
35+
refresh();
1436
}
1537
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ public class LevelRendererMixin {
1616
// +10% FPS under water
1717
@Inject(at = @At("HEAD"), method = "renderSky", cancellable = true)
1818
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();
19+
if (PerformanceBoost.DONT_RENDER_SKY_UNDER_WATER && camera.getFluidInCamera() != FogType.NONE) ci.cancel();
2020
}
2121
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package simpleclient.mixin.performance;
2+
3+
import net.minecraft.client.CloudStatus;
4+
import net.minecraft.client.Options;
5+
import org.spongepowered.asm.mixin.Mixin;
6+
import org.spongepowered.asm.mixin.injection.At;
7+
import org.spongepowered.asm.mixin.injection.Inject;
8+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
9+
import simpleclient.feature.PerformanceBoost;
10+
11+
@Mixin(Options.class)
12+
public class OptionsMixin {
13+
// +20% FPS
14+
@Inject(at = @At("HEAD"), method = "getCloudsType", cancellable = true)
15+
private void getCloudsType(CallbackInfoReturnable<CloudStatus> cir) {
16+
if (PerformanceBoost.DONT_RENDER_CLOUDS) cir.setReturnValue(CloudStatus.OFF);
17+
}
18+
}

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.ENABLED) ci.cancel();
15+
if (PerformanceBoost.FASTBOOT) ci.cancel();
1616
}
1717
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"client": [
99
"GuiMixin",
1010
"performance.LevelRendererMixin",
11+
"performance.OptionsMixin",
1112
"performance.SharedConstantsMixin"
1213
],
1314
"injectors": {
Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,37 @@
11
package simpleclient.feature;
22

3+
import com.google.gson.JsonObject;
4+
import net.minecraft.network.chat.Component;
5+
import simpleclient.feature.config.EnableConfigEntry;
6+
37
public class PerformanceBoost extends EnableableFeature {
4-
public static PerformanceBoost INSTANCE = new PerformanceBoost();
5-
public static boolean ENABLED = INSTANCE.isEnabled();
8+
public static boolean ENABLED = false;
9+
public static boolean FASTBOOT = false;
10+
public static boolean DONT_RENDER_CLOUDS = false;
11+
public static boolean DONT_RENDER_SKY_UNDER_WATER = false;
12+
private final EnableConfigEntry fastBoot = new EnableConfigEntry("fastboot", Component.translatable("simpleclient.performance.fastboot"), true);
13+
private final EnableConfigEntry dontRenderCouds = new EnableConfigEntry("dont_render_clouds", Component.translatable("simpleclient.performance.dont_render_clouds"), true);
14+
private final EnableConfigEntry dontRenderSkyUnderWater = new EnableConfigEntry("dont_render_sky_under_water", Component.translatable("simpleclient.performance.dont_render_sky_under_water"), true);
15+
616
public PerformanceBoost() {
717
super(FeatureType.PERFORMANCE_BOOST);
18+
addConfigEntry(fastBoot);
19+
addConfigEntry(dontRenderCouds);
20+
addConfigEntry(dontRenderSkyUnderWater);
21+
refresh();
22+
}
23+
24+
public void refresh() {
25+
ENABLED = isEnabled();
26+
JsonObject data = getData();
27+
FASTBOOT = ENABLED && fastBoot.load(data);
28+
DONT_RENDER_CLOUDS = ENABLED && dontRenderCouds.load(data);
29+
DONT_RENDER_SKY_UNDER_WATER = ENABLED && dontRenderSkyUnderWater.load(data);
830
}
931

1032
@Override
11-
public void setEnabled(boolean enabled) {
12-
super.setEnabled(enabled);
13-
ENABLED = enabled;
33+
public void setData(JsonObject data) {
34+
super.setData(data);
35+
refresh();
1436
}
1537
}

simpleclient-1.20/src/main/java/simpleclient/mixin/performance/LevelRendererMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ public class LevelRendererMixin {
1616
// +10% FPS under water
1717
@Inject(at = @At("HEAD"), method = "renderSky", cancellable = true)
1818
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();
19+
if (PerformanceBoost.DONT_RENDER_SKY_UNDER_WATER && camera.getFluidInCamera() != FogType.NONE) ci.cancel();
2020
}
2121
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package simpleclient.mixin.performance;
2+
3+
import net.minecraft.client.CloudStatus;
4+
import net.minecraft.client.Options;
5+
import org.spongepowered.asm.mixin.Mixin;
6+
import org.spongepowered.asm.mixin.injection.At;
7+
import org.spongepowered.asm.mixin.injection.Inject;
8+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
9+
import simpleclient.feature.PerformanceBoost;
10+
11+
@Mixin(Options.class)
12+
public class OptionsMixin {
13+
// +20% FPS
14+
@Inject(at = @At("HEAD"), method = "getCloudsType", cancellable = true)
15+
private void getCloudsType(CallbackInfoReturnable<CloudStatus> cir) {
16+
if (PerformanceBoost.DONT_RENDER_CLOUDS) cir.setReturnValue(CloudStatus.OFF);
17+
}
18+
}

simpleclient-1.20/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.FASTBOOT) ci.cancel();
1616
}
1717
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"client": [
99
"GuiMixin",
1010
"performance.LevelRendererMixin",
11+
"performance.OptionsMixin",
1112
"performance.SharedConstantsMixin"
1213
],
1314
"injectors": {

0 commit comments

Comments
 (0)