Skip to content

Commit

Permalink
new: Add basic cloud distance slider (#361)
Browse files Browse the repository at this point in the history
  • Loading branch information
sisby-folk authored Sep 29, 2023
1 parent 1ac5841 commit cc29e9f
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public static CaffeineConfig mixinConfig() {
.addMixinOption("sodium", true)
.addMixinOption("sodium.accessibility", true)
.addMixinOption("sodium.fog", true)
.addMixinOption("sodium.cloud", true)
.addMixinOption("sodium.resolution", true)
.addMixinOption("sodium.scrollable_page", true)
.addMixinOption("sodium.vsync", true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,14 @@ public static OptionPage extra() {
.setBinding((options, value) -> options.extraSettings.cloudHeight = value, options -> options.extraSettings.cloudHeight)
.build()
)
.add(OptionImpl.createBuilder(int.class, sodiumExtraOpts)
.setEnabled(SodiumExtraClientMod.mixinConfig().getOptions().get("mixin.sodium.cloud").isEnabled())
.setName(Text.translatable("sodium-extra.option.cloud_distance"))
.setTooltip(Text.translatable("sodium-extra.option.cloud_distance.tooltip"))
.setControl(option -> new SliderControl(option, 100, 300, 10, ControlValueFormatter.percentage()))
.setBinding((options, value) -> options.extraSettings.cloudDistance = value, options -> options.extraSettings.cloudDistance)
.build()
)
.build());
groups.add(OptionGroup.createBuilder()
.add(OptionImpl.createBuilder(boolean.class, vanillaOpts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ public static class ExtraSettings {
public boolean reduceResolutionOnMac;
public boolean useAdaptiveSync;
public int cloudHeight;
public int cloudDistance;
public boolean toasts;
public boolean advancementToast;
public boolean recipeToast;
Expand All @@ -262,6 +263,7 @@ public ExtraSettings() {
this.reduceResolutionOnMac = false;
this.useAdaptiveSync = false;
this.cloudHeight = 192;
this.cloudDistance = 100;
this.toasts = true;
this.advancementToast = true;
this.recipeToast = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package me.flashyreese.mods.sodiumextra.mixin.sodium.cloud;

import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod;
import me.jellysquid.mods.sodium.client.render.immediate.CloudRenderer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;

@Mixin(CloudRenderer.class)
public class MixinCloudRenderer {
@ModifyVariable(method = "render", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/client/option/GameOptions;getClampedViewDistance()I"), ordinal = 0)
public int modifyCloudRenderDistance(int original) {
return original * SodiumExtraClientMod.options().extraSettings.cloudDistance / 100;
}
}
2 changes: 2 additions & 0 deletions src/main/resources/assets/sodium-extra/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@
"sodium-extra.option.block_breaking.tooltip": "If enabled, block breaking particles are processed.",
"sodium-extra.option.cloud_height": "Cloud Height",
"sodium-extra.option.cloud_height.tooltip": "Controls the height of clouds that are rendered.",
"sodium-extra.option.cloud_distance": "Cloud Distance",
"sodium-extra.option.cloud_distance.tooltip": "Controls the distance away from the player that clouds are rendered.",
"sodium-extra.option.details": "Details",
"sodium-extra.option.enchanting_table_book": "Enchanting Table Book",
"sodium-extra.option.enchanting_table_book.tooltip": "If enabled, enchanting table books are rendered.",
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/sodium-extra.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"sky.MixinWorldRenderer",
"sky_colors.MixinBiome",
"sodium.accessibility.MixinSodiumGameOptionPages",
"sodium.cloud.MixinCloudRenderer",
"sodium.fog.MixinOcclusionCuller",
"sodium.resolution.MixinSodiumGameOptionPages",
"sodium.scrollable_page.MixinSodiumOptionsGUI",
Expand Down

0 comments on commit cc29e9f

Please sign in to comment.