Skip to content

Commit

Permalink
Merge pull request #23 from tildejustin/mac/1.16.1
Browse files Browse the repository at this point in the history
fog occlusion and slider fix
  • Loading branch information
tildejustin authored Jun 12, 2024
2 parents e04e7ab + 0b17e19 commit 5ae4076
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 46 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ yarn_mappings=1.16.1+build.21
loader_version=0.15.7

# Mod Properties
mod_version=3.1.2
mod_version=3.2.0
maven_group=me.jellysquid.mods
archives_base_name=sodium-fabric
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ public static OptionPage quality() {

public static OptionPage advanced() {
boolean disableBlacklist = SodiumClientMod.options().advanced.disableDriverBlacklist;
boolean usePlanarFog = SodiumClientMod.options().unofficial.usePlanarFog;

List<OptionGroup> groups = new ArrayList<>();

Expand Down Expand Up @@ -328,11 +327,25 @@ public static OptionPage unofficial() {
"in areas with thick fog such as in the nether. This is vanilla behavior on systems where GL_NV_fog_distance is unavailable, but is not " +
"considered desirable for any reason other than visibility. This option is not included in official releases of Sodium.")
.setControl(TickBoxControl::new)
.setBinding((opts, value) -> opts.unofficial.usePlanarFog = value, opts -> opts.unofficial.usePlanarFog)
.setBinding((opts, value) -> opts.speedrun.usePlanarFog = value, opts -> opts.speedrun.usePlanarFog)
.setImpact(OptionImpact.MEDIUM)
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD)
.build()
)
.add(OptionImpl.createBuilder(boolean.class, sodiumOpts)
.setName("Show Entity Culling")
.setTooltip("If enabled, Entity Culling will be added to the vanilla menu so it can be toggled while in a world.")
.setControl(TickBoxControl::new)
.setBinding((opts, value) -> opts.speedrun.showEntityCulling = value, opts -> opts.speedrun.showEntityCulling)
.build()
)
.add(OptionImpl.createBuilder(boolean.class, sodiumOpts)
.setName("Show Fog Occlusion")
.setTooltip("If enabled, Fog Occlusion will be added to the vanilla menu so it can be toggled while in a world.")
.setControl(TickBoxControl::new)
.setBinding((opts, value) -> opts.speedrun.showFogOcclusion = value, opts -> opts.speedrun.showFogOcclusion)
.build()
)
.build());
return new OptionPage("Speedrun", ImmutableList.copyOf(groups));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
public class SodiumGameOptions {
public final QualitySettings quality = new QualitySettings();
public final AdvancedSettings advanced = new AdvancedSettings();
public final SettingsSettings settings = new SettingsSettings();
public final UnofficialSettings unofficial = new UnofficialSettings();
public final SpeedrunSettings speedrun = new SpeedrunSettings();

private File file;

Expand All @@ -47,8 +46,10 @@ public static class QualitySettings {
public boolean enableVignette = true;
}

public static class UnofficialSettings {
public static class SpeedrunSettings {
public boolean usePlanarFog = true;
public boolean showEntityCulling = true;
public boolean showFogOcclusion = true;
}

public enum ChunkRendererBackendOption implements TextProvider {
Expand Down Expand Up @@ -96,10 +97,6 @@ private interface SupportCheck {
}
}

public static class SettingsSettings {
public boolean forceVanillaSettings = false;
}

public enum GraphicsQuality implements TextProvider {
DEFAULT("Default"),
FANCY("Fancy"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package me.jellysquid.mods.sodium.client.gui;

import me.jellysquid.mods.sodium.client.gui.vanilla.builders.CycleOptionBuilder;
import me.jellysquid.mods.sodium.client.gui.vanilla.options.EntityCulling;
import me.jellysquid.mods.sodium.client.gui.vanilla.options.BooleanCyclingOption;
import net.minecraft.client.options.Option;

import java.util.HashSet;
Expand All @@ -24,12 +24,21 @@ public static void addSettingsChange(Runnable apply){
DOUBLE_OPTIONS_RUNNABLE.add(apply);
}

public static final Option ENTITY_CULLING = new CycleOptionBuilder<EntityCulling>()
public static final Option ENTITY_CULLING = new CycleOptionBuilder<BooleanCyclingOption>()
.setKey("options.entityCulling")
.setText("Entity Culling")
.setOptions(EntityCulling.values())
.setGetter((options) -> EntityCulling.getOption(options.advanced.useEntityCulling))
.setOptions(BooleanCyclingOption.values())
.setGetter((options) -> BooleanCyclingOption.getOption(options.advanced.useEntityCulling))
.setSetter((options, value) -> options.advanced.useEntityCulling = value.isEnabled())
.setTextGetter(EntityCulling::getText)
.setTextGetter(BooleanCyclingOption::getText)
.build();

public static final Option FOG_OCCLUSION = new CycleOptionBuilder<BooleanCyclingOption>()
.setKey("options.fogOcclusion")
.setText("Fog Occlusion")
.setOptions(BooleanCyclingOption.values())
.setGetter(options -> BooleanCyclingOption.getOption(options.advanced.useFogOcclusion))
.setSetter((options, value) -> options.advanced.useFogOcclusion = value.isEnabled())
.setTextGetter(BooleanCyclingOption::getText)
.build();
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;

public enum EntityCulling implements IndexedOption {

public enum BooleanCyclingOption implements IndexedOption {
ON(0, true, "options.on"),
OFF(1, false, "options.off");

private final int index;
private final boolean enabled;
private final Text text;
EntityCulling(int index, boolean enabled, String translationKey){

BooleanCyclingOption(int index, boolean enabled, String translationKey) {
this.index = index;
this.enabled = enabled;
this.text = new TranslatableText(translationKey);
Expand All @@ -30,8 +30,8 @@ public Text getText() {
return text;
}

public static EntityCulling getOption(boolean value){
if(value){
public static BooleanCyclingOption getOption(boolean value) {
if (value) {
return ON;
}
return OFF;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ private void init(Camera camera, FrustumExtended frustum, int frame, boolean spe

if (dist != 0.0f) {
this.useFogCulling = true;
if (SodiumClientMod.options().unofficial.usePlanarFog) {
if (SodiumClientMod.options().speedrun.usePlanarFog) {
this.usePlanarFog = true;
}
this.fogRenderCutoff = Math.max(FOG_PLANE_MIN_DISTANCE, dist * dist);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static ChunkFogMode getActiveMode() {

int mode = GL11.glGetInteger(GL11.GL_FOG_MODE);

boolean usePlanarFog = SodiumClientMod.options().unofficial.usePlanarFog;
boolean usePlanarFog = SodiumClientMod.options().speedrun.usePlanarFog;

switch (mode) {
case GL11.GL_EXP2:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
public abstract class MixinBackgroundRenderer {
@Redirect(method = "applyFog", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;setupNvFogDistance()V"))
private static void redirectSetupNvFogDistance() {
if (SodiumClientMod.options().unofficial.usePlanarFog) {
if (SodiumClientMod.options().speedrun.usePlanarFog) {
return;
} else {
RenderSystem.setupNvFogDistance();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package me.jellysquid.mods.sodium.mixin.features.options;

import me.jellysquid.mods.sodium.client.SodiumClientMod;
import me.jellysquid.mods.sodium.client.gui.SodiumGameOptions;
import me.jellysquid.mods.sodium.client.gui.SodiumOptionsGUI;
import me.jellysquid.mods.sodium.client.gui.VanillaOptions;
import me.jellysquid.mods.sodium.client.gui.options.OptionFlag;
Expand All @@ -21,7 +22,9 @@
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;

@Mixin(VideoOptionsScreen.class)
Expand All @@ -31,29 +34,17 @@ public MixinVideoOptionsScreen(Screen parent, GameOptions gameOptions, Text titl
super(parent, gameOptions, title);
}

private static final Option[] OPTIONS = {
Option.GRAPHICS,
Option.RENDER_DISTANCE,
Option.AO,
Option.FRAMERATE_LIMIT,
Option.VSYNC,
Option.VIEW_BOBBING,
Option.GUI_SCALE,
Option.ATTACK_INDICATOR,
Option.GAMMA,
Option.CLOUDS,
Option.FULLSCREEN,
Option.PARTICLES,
Option.MIPMAP_LEVELS,
Option.ENTITY_SHADOWS,
Option.ENTITY_DISTANCE_SCALING,
VanillaOptions.ENTITY_CULLING
};

@Redirect(method = "init", at=@At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/ButtonListWidget;addAll([Lnet/minecraft/client/options/Option;)V"))
private void optionsSwap(ButtonListWidget list, Option[] old_options){
list.addAll(OPTIONS);
VanillaOptions.clearSettingsChanges();
private void optionsSwap(ButtonListWidget list, Option[] old_options) {
List<Option> options = new ArrayList<>(Arrays.asList(old_options));
SodiumGameOptions.SpeedrunSettings speedrunSettings = SodiumClientMod.options().speedrun;
if (speedrunSettings.showEntityCulling) {
options.add(VanillaOptions.ENTITY_CULLING);
}
if (speedrunSettings.showFogOcclusion) {
options.add(VanillaOptions.FOG_OCCLUSION);
}
list.addAll(options.toArray(new Option[0]));
}

@Inject(method = "mouseReleased", at = @At("RETURN"))
Expand Down

0 comments on commit 5ae4076

Please sign in to comment.