Skip to content

Commit

Permalink
Merge pull request #7 from tildejustin/1.16.1
Browse files Browse the repository at this point in the history
1.16.1 - use gameoptions variables, remove seperate weather quality, and duplicate cloud options
  • Loading branch information
Knawk authored May 7, 2024
2 parents 7e4905f + 03c6c55 commit c9fbf98
Show file tree
Hide file tree
Showing 17 changed files with 40 additions and 300 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ repositories {

dependencies {
minecraft "com.mojang:minecraft:$minecraft_version"
mappings "com.github.redlime:yarn:$yarn_mappings:v2"
mappings "dev.tildejustin:yarn:$yarn_mappings:v2"
modImplementation "net.fabricmc:fabric-loader:$loader_version"
}

Expand Down
5 changes: 2 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
org.gradle.jvmargs = -Xmx2G
org.gradle.parallel = true
org.gradle.caching = true
loom.mixin.useLegacyMixinAp = false

mod_version = 2.0.2
mod_version = 2.1.0
minecraft_version = 1.16.1
yarn_mappings = 1.16.1.build.19
yarn_mappings = 1.16.1-build.22
loader_version = 0.15.6
target_version = 1.16.1
archives_name = sodium
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@
import me.jellysquid.mods.sodium.client.render.chunk.backends.multidraw.MultidrawChunkRenderBackend;
import me.jellysquid.mods.sodium.client.util.UnsafeUtil;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gl.Framebuffer;
import net.minecraft.client.options.AttackIndicator;
import net.minecraft.client.options.GraphicsMode;
import net.minecraft.client.options.Option;
import net.minecraft.client.options.ParticlesOption;
import net.minecraft.client.options.*;
import net.minecraft.client.util.Window;

import java.util.ArrayList;
Expand Down Expand Up @@ -45,22 +42,6 @@ public static OptionPage general() {
.setControl(opt -> new SliderControl(opt, 0, 500, 1, ControlValueFormatter.brightness()))
.setBinding((opts, value) -> opts.gamma = value * 0.01D, (opts) -> (int) (opts.gamma / 0.01D))
.build())
.add(OptionImpl.createBuilder(boolean.class, sodiumOpts)
.setName("Clouds")
.setTooltip("Controls whether or not clouds will be visible.")
.setControl(TickBoxControl::new)
.setBinding((opts, value) -> {
opts.quality.enableClouds = value;

if (MinecraftClient.isFabulousGraphicsOrBetter()) {
Framebuffer framebuffer = MinecraftClient.getInstance().worldRenderer.getCloudsFramebuffer();
if (framebuffer != null) {
framebuffer.clear(MinecraftClient.IS_SYSTEM_MAC);
}
}
}, (opts) -> opts.quality.enableClouds)
.setImpact(OptionImpact.LOW)
.build())
.build());

groups.add(OptionGroup.createBuilder()
Expand Down Expand Up @@ -151,19 +132,13 @@ public static OptionPage quality() {
.build());

groups.add(OptionGroup.createBuilder()
.add(OptionImpl.createBuilder(SodiumGameOptions.GraphicsQuality.class, sodiumOpts)
.add(OptionImpl.createBuilder(CloudRenderMode.class, vanillaOpts)
.setName("Clouds Quality")
.setTooltip("Controls the quality of rendered clouds in the sky.")
.setControl(option -> new CyclingControl<>(option, SodiumGameOptions.GraphicsQuality.class))
.setBinding((opts, value) -> opts.quality.cloudQuality = value, opts -> opts.quality.cloudQuality)
.setControl(option -> new CyclingControl<>(option, CloudRenderMode.class, new String[] { "Off", "Fast", "Fancy" }))
.setBinding((opts, value) -> opts.cloudRenderMode = value, opts -> opts.cloudRenderMode)
.setImpact(OptionImpact.LOW)
.build())
.add(OptionImpl.createBuilder(SodiumGameOptions.GraphicsQuality.class, sodiumOpts)
.setName("Weather Quality")
.setTooltip("Controls the quality of rain and snow effects.")
.setControl(option -> new CyclingControl<>(option, SodiumGameOptions.GraphicsQuality.class))
.setBinding((opts, value) -> opts.quality.weatherQuality = value, opts -> opts.quality.weatherQuality)
.setImpact(OptionImpact.MEDIUM)
.setFlags(OptionFlag.REQUIRES_CLOUD_RELOAD)
.build())
.add(OptionImpl.createBuilder(ParticlesOption.class, vanillaOpts)
.setName("Particle Quality")
Expand All @@ -172,15 +147,13 @@ public static OptionPage quality() {
.setBinding((opts, value) -> opts.particles = value, (opts) -> opts.particles)
.setImpact(OptionImpact.MEDIUM)
.build())
.add(OptionImpl.createBuilder(SodiumGameOptions.LightingQuality.class, sodiumOpts)
.add(OptionImpl.createBuilder(AoOption.class, vanillaOpts)
.setName("Smooth Lighting")
.setTooltip("Controls the quality of smooth lighting effects.\n" +
"\nOff - No smooth lighting" +
"\nLow - Smooth block lighting only" +
"\nHigh (new!) - Smooth block and entity lighting")
.setControl(option -> new CyclingControl<>(option, SodiumGameOptions.LightingQuality.class))
.setBinding((opts, value) -> opts.quality.smoothLighting = value, opts -> opts.quality.smoothLighting)
.setImpact(OptionImpact.MEDIUM)
.setTooltip("Controls whether blocks will be smoothly lit and shaded. This slightly increases the amount " +
"of time needed to re-build a chunk, but doesn't affect frame rates.")
.setControl(option -> new CyclingControl<>(option, AoOption.class, new String[] { "Off", "Minimum", "Maximum" }))
.setBinding((opts, value) -> opts.ao = value, opts -> opts.ao)
.setImpact(OptionImpact.LOW)
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD)
.build())
.add(OptionImpl.createBuilder(int.class, vanillaOpts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
import com.google.gson.FieldNamingPolicy;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonSyntaxException;
import me.jellysquid.mods.sodium.client.SodiumClientMod;
import me.jellysquid.mods.sodium.client.gui.options.TextProvider;
import net.minecraft.client.options.GraphicsMode;

import java.io.FileReader;
import java.io.IOException;
Expand All @@ -19,7 +18,6 @@ public class SodiumGameOptions {
public final AdvancedSettings advanced = new AdvancedSettings();
public final NotificationSettings notifications = new NotificationSettings();
public final SpeedrunSettings speedrun = new SpeedrunSettings();
public final SettingsSettings settings = new SettingsSettings();

private Path configPath;

Expand All @@ -42,13 +40,7 @@ public static class AdvancedSettings {
}

public static class QualitySettings {
public GraphicsQuality cloudQuality = GraphicsQuality.DEFAULT;
public GraphicsQuality weatherQuality = GraphicsQuality.DEFAULT;

public boolean enableVignette = true;
public boolean enableClouds = true;

public LightingQuality smoothLighting = LightingQuality.HIGH;
}

public static class NotificationSettings {
Expand All @@ -59,64 +51,24 @@ public static class SpeedrunSettings {
public boolean usePlanarFog = true;
}

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

public enum GraphicsQuality implements TextProvider {
DEFAULT("Default"),
FANCY("Fancy"),
FAST("Fast");

private final String name;

GraphicsQuality(String name) {
this.name = name;
}

@Override
public String getLocalizedName() {
return this.name;
}

public boolean isFancy(GraphicsMode graphicsMode) {
return (this == FANCY) || (this == DEFAULT && (graphicsMode == GraphicsMode.FANCY || graphicsMode == GraphicsMode.FABULOUS));
}
}

public enum LightingQuality implements TextProvider {
HIGH("High"),
LOW("Low"),
OFF("Off");

private final String name;

LightingQuality(String name) {
this.name = name;
}

@Override
public String getLocalizedName() {
return this.name;
}
}

private static final Gson GSON = new GsonBuilder()
.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
.setPrettyPrinting()
.excludeFieldsWithModifiers(Modifier.PRIVATE)
.create();

public static SodiumGameOptions load(Path path) {
SodiumGameOptions config;
SodiumGameOptions config = null;

if (Files.exists(path)) {
boolean exists = Files.exists(path);
if (exists) {
try (FileReader reader = new FileReader(path.toFile())) {
config = GSON.fromJson(reader, SodiumGameOptions.class);
} catch (IOException e) {
throw new RuntimeException("Could not parse config", e);
} catch (IOException | JsonSyntaxException e) {
SodiumClientMod.logger().warn("Could not parse config, falling back to default");
}
} else {
}
if (!exists || config == null) {
config = new SodiumGameOptions();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package me.jellysquid.mods.sodium.client.gui;

import me.jellysquid.mods.sodium.client.gui.options.OptionFlag;
import me.jellysquid.mods.sodium.client.gui.vanilla.builders.CycleOptionBuilder;
import me.jellysquid.mods.sodium.client.gui.vanilla.options.CloudsOptions;
import me.jellysquid.mods.sodium.client.gui.vanilla.options.EntityCulling;
import me.jellysquid.mods.sodium.client.gui.vanilla.options.SmoothLightingOptions;
import net.minecraft.client.options.*;
import net.minecraft.client.options.Option;

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

public static final Option SMOOTH_LIGHTING = new CycleOptionBuilder<SmoothLightingOptions>()
.setKey("options.ao")
.setOptions(SmoothLightingOptions.values())
.setGetter((options) -> SmoothLightingOptions.getOption(options.quality.smoothLighting))
.setSetter(((options, smoothLightingOption) -> options.quality.smoothLighting = smoothLightingOption.getSmoothLighting()))
.setTextGetter(SmoothLightingOptions::getText)
.flag(OptionFlag.REQUIRES_RENDERER_RELOAD)
.build();

public static final Option CLOUDS = new CycleOptionBuilder<CloudsOptions>()
.setKey("options.renderClouds")
.setOptions(CloudsOptions.values())
.setGetter((options) -> CloudsOptions.getOption(options.quality.enableClouds, options.quality.cloudQuality))
.setSetter((options, value) -> {
options.quality.enableClouds = value.isEnabled();
options.quality.cloudQuality = value.getQuality();
})
.flag(OptionFlag.REQUIRES_CLOUD_RELOAD)
.setTextGetter(CloudsOptions::getText)
.build();

public static final Option ENTITY_CULLING = new CycleOptionBuilder<EntityCulling>()
.setKey("options.entityCulling")
.setText("Entity Culling")
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
@Mixin(BufferBuilder.class)
public abstract class MixinBufferBuilder extends FixedColorVertexConsumer {
@Shadow
private boolean field_21594; // is baked quad format
private boolean canSkipElementChecks; // is baked quad format

@Override
public void quad(MatrixStack.Entry matrices, BakedQuad quad, float[] brightnessTable, float r, float g, float b, int[] light, int overlay, boolean colorize) {
if (!this.field_21594) {
if (!this.canSkipElementChecks) {
super.quad(matrices, quad, brightnessTable, r, g, b, light, overlay, colorize);

return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package me.jellysquid.mods.sodium.mixin.features.entity.smooth_lighting;

import me.jellysquid.mods.sodium.client.SodiumClientMod;
import me.jellysquid.mods.sodium.client.gui.SodiumGameOptions;
import me.jellysquid.mods.sodium.client.model.light.EntityLighter;
import me.jellysquid.mods.sodium.client.render.SodiumWorldRenderer;
import me.jellysquid.mods.sodium.client.render.entity.EntityLightSampler;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.options.AoOption;
import net.minecraft.client.render.Frustum;
import net.minecraft.client.render.entity.EntityRenderer;
import net.minecraft.entity.Entity;
Expand All @@ -27,7 +26,7 @@ public abstract class MixinEntityRenderer<T extends Entity> implements EntityLig
@Inject(method = "getLight", at = @At("HEAD"), cancellable = true)
private void preGetLight(T entity, float tickDelta, CallbackInfoReturnable<Integer> cir) {
// Use smooth entity lighting if enabled
if (SodiumClientMod.options().quality.smoothLighting == SodiumGameOptions.LightingQuality.HIGH) {
if (MinecraftClient.getInstance().options.ao == AoOption.MAX) {
cir.setReturnValue(EntityLighter.getBlendedLight(this, entity, tickDelta));
}
}
Expand Down
Loading

0 comments on commit c9fbf98

Please sign in to comment.