From a6fee3eb4058a24ff55eb4bd6763a1ed6769eaac Mon Sep 17 00:00:00 2001 From: contaria Date: Sat, 20 Apr 2024 07:16:15 +0200 Subject: [PATCH] fix graphicsMode setting on devices that dont support fabulous graphics --- .../standardsettings/StandardSettingsConfig.java | 16 +++++++++++++++- .../standardsettings/mixin/fix/OptionMixin.java | 5 +++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/contaria/standardsettings/StandardSettingsConfig.java b/src/main/java/me/contaria/standardsettings/StandardSettingsConfig.java index 2228d40a..053994f0 100644 --- a/src/main/java/me/contaria/standardsettings/StandardSettingsConfig.java +++ b/src/main/java/me/contaria/standardsettings/StandardSettingsConfig.java @@ -1,6 +1,7 @@ package me.contaria.standardsettings; import com.google.gson.JsonParseException; +import com.mojang.blaze3d.platform.GlStateManager; import me.contaria.standardsettings.options.*; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.screen.Screen; @@ -103,7 +104,20 @@ public class StandardSettingsConfig implements SpeedrunConfig { }, (options, doubleOption) -> option.getText()).createButton(options, 0, 0, 120); }); this.register("biomeBlendRadius", "options.video", Option.BIOME_BLEND_RADIUS); - this.register("graphicsMode", "options.video", Option.GRAPHICS, options -> options.graphicsMode.getId()); + this.register(new CyclingOptionStandardSetting("graphicsMode", "options.video", this.options, Option.GRAPHICS, options -> options.graphicsMode.getId()) { + @Override + public void set(GameOptions options, Integer value) { + // see Option.GRAPHICS's setter + options.graphicsMode = GraphicsMode.byId(value); + if (!(options instanceof StandardGameOptions)) { + if (options.graphicsMode == GraphicsMode.FABULOUS && (!GlStateManager.supportsGl30() || MinecraftClient.getInstance().method_30049().method_30142())) { + StandardSettings.LOGGER.warn("Set Graphics Mode to 'Fancy' because 'Fabulous!' is not supported on this device."); + options.graphicsMode = GraphicsMode.FANCY; + } + MinecraftClient.getInstance().worldRenderer.reload(); + } + } + }); this.register("renderDistance", "options.video", Option.RENDER_DISTANCE); this.register("ao", "options.video", Option.AO, options -> options.ao.getValue()); this.register("maxFps", "options.video", Option.FRAMERATE_LIMIT); diff --git a/src/main/java/me/contaria/standardsettings/mixin/fix/OptionMixin.java b/src/main/java/me/contaria/standardsettings/mixin/fix/OptionMixin.java index 51710a54..0926dca3 100644 --- a/src/main/java/me/contaria/standardsettings/mixin/fix/OptionMixin.java +++ b/src/main/java/me/contaria/standardsettings/mixin/fix/OptionMixin.java @@ -49,4 +49,9 @@ private static Window doNotModifyWindow(Window window, @Local(argsOnly = true) G } return window; } + + @ModifyExpressionValue(method = "method_18554", at = @At(value = "INVOKE", target = "Lnet/minecraft/class_5407;method_30137()Z")) + private static boolean doNotWarnAboutFabulousGraphics(boolean original, @Local(argsOnly = true) GameOptions options) { + return original && !(options instanceof StandardGameOptions); + } }