From a3df549f85122143f4ebdbe5b624b8b9bf8868a0 Mon Sep 17 00:00:00 2001 From: IMS Date: Sun, 15 Sep 2024 13:14:51 -0700 Subject: [PATCH 1/2] Fix issues with Beta 2 update (#414) --- .../client/SodiumExtraClientMod.java | 6 +- .../OptionPageScrollFrame.java | 2 +- .../mixin/sky/MixinLevelRenderer.java | 8 ++- .../MixinSodiumGameOptionPages.java | 64 ------------------- .../MixinSodiumOptionsGUI.java | 2 +- .../vsync/MixinSodiumGameOptionsPages.java | 3 +- .../mixin/stars/MixinLevelRenderer.java | 8 ++- .../mixin/sun_moon/MixinLevelRenderer.java | 8 ++- .../main/resources/sodium-extra.mixins.json | 1 - 9 files changed, 22 insertions(+), 80 deletions(-) delete mode 100644 common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/resolution/MixinSodiumGameOptionPages.java diff --git a/common/src/main/java/me/flashyreese/mods/sodiumextra/client/SodiumExtraClientMod.java b/common/src/main/java/me/flashyreese/mods/sodiumextra/client/SodiumExtraClientMod.java index ca8ae337..5358c957 100644 --- a/common/src/main/java/me/flashyreese/mods/sodiumextra/client/SodiumExtraClientMod.java +++ b/common/src/main/java/me/flashyreese/mods/sodiumextra/client/SodiumExtraClientMod.java @@ -60,7 +60,7 @@ public static CaffeineConfig mixinConfig() { .addMixinOption("render.block", true) .addMixinOption("render.block.entity", true) .addMixinOption("render.entity", true) - .addMixinOption("sky", false) + .addMixinOption("sky", true) .addMixinOption("sky_colors", true) .addMixinOption("sodium", true) .addMixinOption("sodium.accessibility", true) @@ -69,9 +69,9 @@ public static CaffeineConfig mixinConfig() { .addMixinOption("sodium.resolution", true) .addMixinOption("sodium.scrollable_page", true) .addMixinOption("sodium.vsync", true) - .addMixinOption("stars", false) + .addMixinOption("stars", true) .addMixinOption("steady_debug_hud", true) - .addMixinOption("sun_moon", false) + .addMixinOption("sun_moon", true) .addMixinOption("toasts", true) //.withLogger(SodiumExtraClientMod.logger()) diff --git a/common/src/main/java/me/flashyreese/mods/sodiumextra/client/gui/scrollable_page/OptionPageScrollFrame.java b/common/src/main/java/me/flashyreese/mods/sodiumextra/client/gui/scrollable_page/OptionPageScrollFrame.java index 3072553a..e4745532 100644 --- a/common/src/main/java/me/flashyreese/mods/sodiumextra/client/gui/scrollable_page/OptionPageScrollFrame.java +++ b/common/src/main/java/me/flashyreese/mods/sodiumextra/client/gui/scrollable_page/OptionPageScrollFrame.java @@ -107,7 +107,7 @@ private void renderOptionTooltip(GuiGraphics guiGraphics, ControlElement elem int textPadding = 3; int boxPadding = 3; - int boxWidth = 200; + int boxWidth = 240; int boxY = Math.max(dim.y(), this.dim.y()); int boxX = this.dim.getLimitX() + boxPadding; diff --git a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sky/MixinLevelRenderer.java b/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sky/MixinLevelRenderer.java index 99b77c0e..519baa92 100644 --- a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sky/MixinLevelRenderer.java +++ b/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sky/MixinLevelRenderer.java @@ -1,5 +1,7 @@ package me.flashyreese.mods.sodiumextra.mixin.sky; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexBuffer; import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; @@ -14,7 +16,7 @@ @Mixin(LevelRenderer.class) public class MixinLevelRenderer { - @Redirect( + @WrapOperation( method = "renderSky", at = @At( value = "INVOKE", @@ -22,9 +24,9 @@ public class MixinLevelRenderer { ordinal = 0 ) ) - public void redirectSetSkyShader(VertexBuffer instance, Matrix4f viewMatrix, Matrix4f projectionMatrix, ShaderInstance program) { + public void redirectSetSkyShader(VertexBuffer instance, Matrix4f viewMatrix, Matrix4f projectionMatrix, ShaderInstance program, Operation original) { if (SodiumExtraClientMod.options().detailSettings.sky) { - instance.drawWithShader(viewMatrix, projectionMatrix, program); + original.call(instance, viewMatrix, projectionMatrix, program); } } diff --git a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/resolution/MixinSodiumGameOptionPages.java b/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/resolution/MixinSodiumGameOptionPages.java deleted file mode 100644 index 0877c4e9..00000000 --- a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/resolution/MixinSodiumGameOptionPages.java +++ /dev/null @@ -1,64 +0,0 @@ -package me.flashyreese.mods.sodiumextra.mixin.sodium.resolution; - -import com.mojang.blaze3d.platform.Monitor; -import com.mojang.blaze3d.platform.VideoMode; -import com.mojang.blaze3d.platform.Window; -import me.flashyreese.mods.sodiumextra.client.gui.options.control.SliderControlExtended; -import me.flashyreese.mods.sodiumextra.common.util.ControlValueFormatterExtended; -import net.caffeinemc.mods.sodium.client.gui.SodiumGameOptionPages; -import net.caffeinemc.mods.sodium.client.gui.options.OptionGroup; -import net.caffeinemc.mods.sodium.client.gui.options.OptionImpact; -import net.caffeinemc.mods.sodium.client.gui.options.OptionImpl; -import net.caffeinemc.mods.sodium.client.gui.options.OptionPage; -import net.caffeinemc.mods.sodium.client.gui.options.storage.MinecraftOptionsStorage; -import net.minecraft.client.Minecraft; -import net.minecraft.network.chat.Component; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; - -import java.util.List; -import java.util.Optional; - -@Mixin(value = SodiumGameOptionPages.class, remap = false) -public class MixinSodiumGameOptionPages { - - @Shadow - @Final - private static MinecraftOptionsStorage vanillaOpts; - - @Inject(method = "general", at = @At(value = "INVOKE", target = "Lnet/caffeinemc/mods/sodium/client/gui/options/OptionGroup;createBuilder()Lnet/caffeinemc/mods/sodium/client/gui/options/OptionGroup$Builder;", ordinal = 1, shift = At.Shift.BEFORE), locals = LocalCapture.CAPTURE_FAILSOFT, remap = false) - private static void general(CallbackInfoReturnable cir, Monitor monitor, List groups) { - Window window = Minecraft.getInstance().getWindow(); - - groups.add(OptionGroup.createBuilder() - .add(OptionImpl.createBuilder(int.class, vanillaOpts) - .setName(Component.translatable("options.fullscreen.resolution")) - .setTooltip(Component.translatable("sodium-extra.option.resolution.tooltip")) - .setControl(option -> new SliderControlExtended(option, 0, window.findBestMonitor() != null ? window.findBestMonitor().getModeCount() : 0, 1, ControlValueFormatterExtended.resolution(), false)) - .setBinding((options, value) -> { - if (window.findBestMonitor() != null) { - if (value == 0) { - window.setPreferredFullscreenVideoMode(Optional.empty()); - } else { - window.setPreferredFullscreenVideoMode(Optional.of(window.findBestMonitor().getMode(value - 1))); - } - } - window.changeFullscreenVideoMode(); - }, options -> { - if (window.findBestMonitor() == null) { - return 0; - } else { - Optional optional = window.getPreferredFullscreenVideoMode(); - return optional.map((videoMode) -> window.findBestMonitor().getVideoModeIndex(videoMode) + 1).orElse(0); - } - }) - .setImpact(OptionImpact.HIGH) - .build()) - .build()); - } -} diff --git a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/scrollable_page/MixinSodiumOptionsGUI.java b/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/scrollable_page/MixinSodiumOptionsGUI.java index 9ba9b43f..a4b936b7 100644 --- a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/scrollable_page/MixinSodiumOptionsGUI.java +++ b/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/scrollable_page/MixinSodiumOptionsGUI.java @@ -34,7 +34,7 @@ private void rebuildGUIOptions(CallbackInfo ci) { int x = 6; int y = 28; - OptionPageScrollFrame optionPageScrollFrame = new OptionPageScrollFrame(new Dim2i(x, y, /*this.width - x * 2*/200, this.height - y - 10 /*- 64*/), this.currentPage); + OptionPageScrollFrame optionPageScrollFrame = new OptionPageScrollFrame(new Dim2i(x, y, /*this.width - x * 2*/240, this.height - y - 10 /*- 64*/), this.currentPage); this.addRenderableWidget(optionPageScrollFrame); ci.cancel(); } diff --git a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/vsync/MixinSodiumGameOptionsPages.java b/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/vsync/MixinSodiumGameOptionsPages.java index b35c1cab..0d885e2e 100644 --- a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/vsync/MixinSodiumGameOptionsPages.java +++ b/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sodium/vsync/MixinSodiumGameOptionsPages.java @@ -7,6 +7,7 @@ import net.caffeinemc.mods.sodium.client.gui.options.OptionGroup; import net.caffeinemc.mods.sodium.client.gui.options.OptionImpact; import net.caffeinemc.mods.sodium.client.gui.options.OptionImpl; +import net.caffeinemc.mods.sodium.client.gui.options.binding.compat.VanillaBooleanOptionBinding; import net.caffeinemc.mods.sodium.client.gui.options.control.CyclingControl; import net.caffeinemc.mods.sodium.client.gui.options.storage.MinecraftOptionsStorage; import net.minecraft.network.chat.Component; @@ -22,7 +23,7 @@ public class MixinSodiumGameOptionsPages { @Final private static MinecraftOptionsStorage vanillaOpts; - @Redirect(method = "general", at = @At(value = "INVOKE", target = "Lnet/caffeinemc/mods/sodium/client/gui/options/OptionGroup$Builder;add(Lnet/caffeinemc/mods/sodium/client/gui/options/Option;)Lnet/caffeinemc/mods/sodium/client/gui/options/OptionGroup$Builder;", ordinal = 5), remap = false) + @Redirect(method = "general", at = @At(value = "INVOKE", target = "Lnet/caffeinemc/mods/sodium/client/gui/options/OptionGroup$Builder;add(Lnet/caffeinemc/mods/sodium/client/gui/options/Option;)Lnet/caffeinemc/mods/sodium/client/gui/options/OptionGroup$Builder;", ordinal = 6), remap = false) private static OptionGroup.Builder redirectVsyncToggle(OptionGroup.Builder instance, Option option) { if (!option.getTooltip().getString().equals(Component.translatable("sodium.options.v_sync.tooltip").getString())) { return instance.add(option); diff --git a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/stars/MixinLevelRenderer.java b/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/stars/MixinLevelRenderer.java index bf03aaa8..bd95b79c 100644 --- a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/stars/MixinLevelRenderer.java +++ b/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/stars/MixinLevelRenderer.java @@ -1,5 +1,7 @@ package me.flashyreese.mods.sodiumextra.mixin.stars; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.renderer.LevelRenderer; @@ -9,16 +11,16 @@ @Mixin(LevelRenderer.class) public class MixinLevelRenderer { - @Redirect( + @WrapOperation( method = "renderSky", at = @At( value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/ClientLevel;getStarBrightness(F)F" ) ) - public float redirectGetStarBrightness(ClientLevel instance, float f) { + public float redirectGetStarBrightness(ClientLevel instance, float f, Operation original) { if (SodiumExtraClientMod.options().detailSettings.stars) { - return instance.getStarBrightness(f); + return original.call(instance, f); } else { return 0.0f; } diff --git a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sun_moon/MixinLevelRenderer.java b/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sun_moon/MixinLevelRenderer.java index e040f151..e4ecdff7 100644 --- a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sun_moon/MixinLevelRenderer.java +++ b/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sun_moon/MixinLevelRenderer.java @@ -1,5 +1,7 @@ package me.flashyreese.mods.sodiumextra.mixin.sun_moon; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; import net.minecraft.client.renderer.DimensionSpecialEffects; import net.minecraft.client.renderer.LevelRenderer; @@ -26,16 +28,16 @@ public class MixinLevelRenderer { @Final private static ResourceLocation MOON_LOCATION; - @Redirect( + @WrapOperation( method = "renderSky", at = @At( value = "INVOKE", target = "Lnet/minecraft/client/renderer/DimensionSpecialEffects;getSunriseColor(FF)[F" ) ) - public float[] redirectGetFogColorOverride(DimensionSpecialEffects instance, float skyAngle, float tickDelta) { + public float[] redirectGetFogColorOverride(DimensionSpecialEffects instance, float skyAngle, float tickDelta, Operation original) { if (SodiumExtraClientMod.options().detailSettings.sunMoon) { - return instance.getSunriseColor(skyAngle, tickDelta); + return original.call(instance, skyAngle, tickDelta); } else { return null; } diff --git a/common/src/main/resources/sodium-extra.mixins.json b/common/src/main/resources/sodium-extra.mixins.json index b1b40c5e..b97a4ca4 100644 --- a/common/src/main/resources/sodium-extra.mixins.json +++ b/common/src/main/resources/sodium-extra.mixins.json @@ -41,7 +41,6 @@ "sodium.accessibility.MixinSodiumGameOptionPages", "sodium.cloud.MixinCloudRenderer", "sodium.fog.MixinOcclusionCuller", - "sodium.resolution.MixinSodiumGameOptionPages", "sodium.scrollable_page.MixinSodiumOptionsGUI", "sodium.vsync.MixinSodiumGameOptionsPages", "stars.MixinLevelRenderer", From b74f5840388a04dbcaa585e2ec1407a596af92b6 Mon Sep 17 00:00:00 2001 From: Yao Chung Hu <30311066+FlashyReese@users.noreply.github.com> Date: Sun, 15 Sep 2024 14:19:18 -0600 Subject: [PATCH 2/2] change: Bump version --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 64be1deb..b5f423d0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -14,7 +14,7 @@ val PARCHMENT_VERSION by extra { null } // https://semver.org/ val MAVEN_GROUP by extra { "me.flashyreese.mods" } val ARCHIVE_NAME by extra { "sodium-extra" } -val MOD_VERSION by extra { "0.6.0-beta.2" } +val MOD_VERSION by extra { "0.6.0-beta.3" } val SODIUM_VERSION by extra { "mc1.21-0.6.0-beta.2" } allprojects {