forked from FlashyReese/sodium-extra-fabric
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ca4a224
commit 03e4807
Showing
9 changed files
with
174 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 4 additions & 9 deletions
13
src/main/java/me/flashyreese/mods/sodiumextra/client/ClientTickHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
src/main/java/me/flashyreese/mods/sodiumextra/client/gui/EmbeddiumExtendedOptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,109 @@ | ||
package me.flashyreese.mods.sodiumextra.client.gui; | ||
|
||
import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; | ||
import me.flashyreese.mods.sodiumextra.client.gui.options.control.SliderControlExtended; | ||
import me.flashyreese.mods.sodiumextra.common.util.ControlValueFormatterExtended; | ||
import me.jellysquid.mods.sodium.client.gui.SodiumGameOptionPages; | ||
import me.jellysquid.mods.sodium.client.gui.options.Option; | ||
import me.jellysquid.mods.sodium.client.gui.options.OptionGroup; | ||
import me.jellysquid.mods.sodium.client.gui.options.OptionImpact; | ||
import me.jellysquid.mods.sodium.client.gui.options.OptionImpl; | ||
import me.jellysquid.mods.sodium.client.gui.options.control.ControlValueFormatter; | ||
import me.jellysquid.mods.sodium.client.gui.options.control.CyclingControl; | ||
import me.jellysquid.mods.sodium.client.gui.options.control.SliderControl; | ||
import me.jellysquid.mods.sodium.client.gui.options.storage.OptionStorage; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.option.GameOptions; | ||
import net.minecraft.client.util.VideoMode; | ||
import net.minecraft.client.util.Window; | ||
import net.minecraft.text.Text; | ||
import net.minecraft.util.Identifier; | ||
|
||
import java.util.Optional; | ||
|
||
public class EmbeddiumExtendedOptions { | ||
private static final OptionStorage<GameOptions> vanillaOpts = SodiumGameOptionPages.getVanillaOpts(); | ||
|
||
public static final Option<?> ADAPTIVE_VSYNC = OptionImpl.createBuilder(SodiumExtraGameOptions.VerticalSyncOption.class, SodiumExtraGameOptionPages.sodiumExtraOpts) | ||
.setName(Text.translatable("options.vsync")) | ||
.setId(new Identifier(SodiumExtraClientMod.MOD_ID, "vsync")) | ||
.setTooltip(Text.literal(Text.translatable("sodium.options.v_sync.tooltip").getString() + "\n- " + Text.translatable("sodium-extra.option.use_adaptive_sync.name").getString() + ": " + Text.translatable("sodium-extra.option.use_adaptive_sync.tooltip").getString())) | ||
.setControl((opt) -> new CyclingControl<>(opt, SodiumExtraGameOptions.VerticalSyncOption.class, | ||
SodiumExtraGameOptions.VerticalSyncOption.getAvailableOptions())) | ||
.setBinding((opts, value) -> { | ||
switch (value) { | ||
case OFF -> { | ||
opts.extraSettings.useAdaptiveSync = false; | ||
vanillaOpts.getData().getEnableVsync().setValue(false); | ||
} | ||
case ON -> { | ||
opts.extraSettings.useAdaptiveSync = false; | ||
vanillaOpts.getData().getEnableVsync().setValue(true); | ||
} | ||
case ADAPTIVE -> { | ||
opts.extraSettings.useAdaptiveSync = true; | ||
vanillaOpts.getData().getEnableVsync().setValue(true); | ||
} | ||
} | ||
vanillaOpts.save(); | ||
}, opts -> { | ||
if (vanillaOpts.getData().getEnableVsync().getValue() && !opts.extraSettings.useAdaptiveSync) { | ||
return SodiumExtraGameOptions.VerticalSyncOption.ON; | ||
} else if (!vanillaOpts.getData().getEnableVsync().getValue() && !opts.extraSettings.useAdaptiveSync) { | ||
return SodiumExtraGameOptions.VerticalSyncOption.OFF; | ||
} else { | ||
return SodiumExtraGameOptions.VerticalSyncOption.ADAPTIVE; | ||
} | ||
}) | ||
.setImpact(OptionImpact.VARIES) | ||
.build(); | ||
|
||
public static final OptionGroup EFFECTS_GROUP = OptionGroup.createBuilder() | ||
.add(OptionImpl.createBuilder(int.class, vanillaOpts) | ||
.setName(Text.translatable("options.screenEffectScale")) | ||
.setTooltip(Text.translatable("options.screenEffectScale.tooltip")) | ||
.setControl(option -> new SliderControl(option, 0, 100, 1, ControlValueFormatter.percentage())) | ||
.setBinding((opts, value) -> opts.getDistortionEffectScale().setValue((double) value / 100.0F), (opts) -> Math.toIntExact(Math.round(opts.getDistortionEffectScale().getValue() * 100.0F))) | ||
.setImpact(OptionImpact.LOW) | ||
.build() | ||
) | ||
.add(OptionImpl.createBuilder(int.class, vanillaOpts) | ||
.setName(Text.translatable("options.fovEffectScale")) | ||
.setTooltip(Text.translatable("options.fovEffectScale.tooltip")) | ||
.setControl(option -> new SliderControl(option, 0, 100, 1, ControlValueFormatter.percentage())) | ||
.setBinding((opts, value) -> opts.getFovEffectScale().setValue(Math.sqrt(value / 100.0F)), (opts) -> (int) Math.round(Math.pow(opts.getFovEffectScale().getValue(), 2.0D) * 100.0F)) | ||
.setImpact(OptionImpact.LOW) | ||
.build() | ||
) | ||
.build(); | ||
|
||
public static final OptionGroup RESOLUTION_GROUP = OptionGroup.createBuilder() | ||
.add(OptionImpl.createBuilder(int.class, vanillaOpts) | ||
.setName(Text.translatable("options.fullscreen.resolution")) | ||
.setTooltip(Text.translatable("sodium-extra.option.resolution.tooltip")) | ||
.setControl(option -> new SliderControlExtended(option, 0, window().getMonitor() != null ? window().getMonitor().getVideoModeCount() : 0, 1, ControlValueFormatterExtended.resolution(), false)) | ||
.setBinding((options, value) -> { | ||
if (window().getMonitor() != null) { | ||
if (value == 0) { | ||
window().setVideoMode(Optional.empty()); | ||
} else { | ||
window().setVideoMode(Optional.of(window().getMonitor().getVideoMode(value - 1))); | ||
} | ||
} | ||
window().applyVideoMode(); | ||
}, options -> { | ||
if (window().getMonitor() == null) { | ||
return 0; | ||
} else { | ||
Optional<VideoMode> optional = window().getVideoMode(); | ||
return optional.map((videoMode) -> window().getMonitor().findClosestVideoModeIndex(videoMode) + 1).orElse(0); | ||
} | ||
}) | ||
.setImpact(OptionImpact.HIGH) | ||
.build()) | ||
.build(); | ||
|
||
private static Window window() { | ||
return MinecraftClient.getInstance().getWindow(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 7 additions & 5 deletions
12
src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/cloud/MixinCloudRenderer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
package me.flashyreese.mods.sodiumextra.mixin.sodium.cloud; | ||
|
||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation; | ||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; | ||
import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; | ||
import me.jellysquid.mods.sodium.client.render.immediate.CloudRenderer; | ||
import net.minecraft.client.option.GameOptions; | ||
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"), index = 21, name = "renderDistance") | ||
public int modifyCloudRenderDistance(int original) { | ||
return original * SodiumExtraClientMod.options().extraSettings.cloudDistance / 100; | ||
@WrapOperation(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/GameOptions;getClampedViewDistance()I")) | ||
public int modifyCloudRenderDistance(GameOptions instance, Operation<Integer> original) { | ||
return original.call(instance) * SodiumExtraClientMod.options().extraSettings.cloudDistance / 100; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters