From 6311679d77423b6bafe229c86dc23f908693b1ca Mon Sep 17 00:00:00 2001 From: Ennui Langeweile <85590273+EnnuiL@users.noreply.github.com> Date: Tue, 15 Oct 2024 19:21:33 -0300 Subject: [PATCH] Prepare for 10.0.0-beta.2 --- .../ok_zoomer/config/OkZoomerConfig.java | 4 ++ .../config/screen/OkZoomerConfigScreen.java | 55 ++++++++++--------- .../mixin/common/GameRendererMixin.java | 11 ++++ .../ok_zoomer/mixin/common/GuiMixin.java | 2 +- .../assets/ok_zoomer/lang/en_us.json | 4 +- .../assets/ok_zoomer/lang/pt_br.json | 4 +- 6 files changed, 50 insertions(+), 30 deletions(-) diff --git a/src/main/java/io/github/ennuil/ok_zoomer/config/OkZoomerConfig.java b/src/main/java/io/github/ennuil/ok_zoomer/config/OkZoomerConfig.java index 6d8db04..ce46bee 100644 --- a/src/main/java/io/github/ennuil/ok_zoomer/config/OkZoomerConfig.java +++ b/src/main/java/io/github/ennuil/ok_zoomer/config/OkZoomerConfig.java @@ -45,6 +45,10 @@ public static class FeaturesConfig extends Section { """) public final TrackedValue zoomTransition = this.value(ZoomTransitionOptions.SMOOTH); + @WidgetSize(Size.HALF) + @Comment("Divides the amount of view bobbing with the zoom divisor while zooming.") + public final TrackedValue reduceViewBobbing = this.value(true); + @WidgetSize(Size.HALF) @Comment(""" "HOLD": The zoom will require the zoom key to be held. diff --git a/src/main/java/io/github/ennuil/ok_zoomer/config/screen/OkZoomerConfigScreen.java b/src/main/java/io/github/ennuil/ok_zoomer/config/screen/OkZoomerConfigScreen.java index c88dc23..fdc1a0d 100644 --- a/src/main/java/io/github/ennuil/ok_zoomer/config/screen/OkZoomerConfigScreen.java +++ b/src/main/java/io/github/ennuil/ok_zoomer/config/screen/OkZoomerConfigScreen.java @@ -56,6 +56,21 @@ protected void init() { var config = Configs.getConfig(this.configId.getNamespace(), this.configId.getPath()); this.configTextUtils = new ConfigTextUtils(config); this.entryListWidget = new OkZoomerAbstractSelectionList(this.minecraft, this.width, this.height - 64, 32); + + this.entryListWidget.addCategory(Component.translatable("config.ok_zoomer.presets")); + var presetButton = CycleButton.builder(value -> Component.translatable(String.format("config.ok_zoomer.presets.preset.%s", value.toString().toLowerCase(Locale.ROOT)))) + .withValues(ConfigEnums.ZoomPresets.values()) + .withTooltip(value -> Tooltip.create(Component.translatable(String.format("config.ok_zoomer.presets.preset.%s.tooltip", value.toString().toLowerCase(Locale.ROOT))))) + .withInitialValue(ConfigEnums.ZoomPresets.DEFAULT) + .create(0, 0, 150, 20, + Component.translatable("config.ok_zoomer.presets.preset")); + var resetButton = Button.builder( + Component.translatable("config.ok_zoomer.presets.apply_preset"), + button -> this.resetToPreset(presetButton.getValue())) + .tooltip(Tooltip.create(Component.translatable("config.ok_zoomer.presets.apply_preset.tooltip"))) + .build(); + this.entryListWidget.addButton(presetButton, resetButton); + for (var node : config.nodes()) { if (node instanceof ValueTreeNode.Section section) { this.entryListWidget.addCategory(this.configTextUtils.getCategoryText(section.key().toString())); @@ -176,20 +191,6 @@ protected void init() { } } - this.entryListWidget.addCategory(Component.translatable("config.ok_zoomer.presets")); - var presetButton = CycleButton.builder(value -> Component.translatable(String.format("config.ok_zoomer.presets.preset.%s", value.toString().toLowerCase(Locale.ROOT)))) - .withValues(ConfigEnums.ZoomPresets.values()) - .withTooltip(value -> Tooltip.create(Component.translatable(String.format("config.ok_zoomer.presets.preset.%s.tooltip", value.toString().toLowerCase(Locale.ROOT))))) - .withInitialValue(ConfigEnums.ZoomPresets.DEFAULT) - .create(0, 0, 150, 20, - Component.translatable("config.ok_zoomer.presets.preset")); - var resetButton = Button.builder( - Component.translatable("config.ok_zoomer.presets.apply_preset"), - button -> this.resetToPreset(presetButton.getValue())) - .tooltip(Tooltip.create(Component.translatable("config.ok_zoomer.presets.apply_preset.tooltip"))) - .build(); - this.entryListWidget.addButton(presetButton, resetButton); - this.entryListWidget.finish(); this.addRenderableWidget(this.entryListWidget); @@ -264,6 +265,10 @@ public void resetToPreset(ConfigEnums.ZoomPresets preset) { Map.entry(OkZoomerConfigManager.CONFIG.features.cinematicCamera, preset == ConfigEnums.ZoomPresets.CLASSIC ? ConfigEnums.CinematicCameraOptions.VANILLA : ConfigEnums.CinematicCameraOptions.OFF), Map.entry(OkZoomerConfigManager.CONFIG.features.reduceSensitivity, preset != ConfigEnums.ZoomPresets.CLASSIC), Map.entry(OkZoomerConfigManager.CONFIG.features.zoomTransition, preset == ConfigEnums.ZoomPresets.CLASSIC ? ConfigEnums.ZoomTransitionOptions.OFF : ConfigEnums.ZoomTransitionOptions.SMOOTH), + Map.entry(OkZoomerConfigManager.CONFIG.features.reduceViewBobbing, switch (preset) { + case CLASSIC, CLASSIC_ZOOMER -> false; + default -> true; + }), Map.entry(OkZoomerConfigManager.CONFIG.features.zoomMode, preset == ConfigEnums.ZoomPresets.PERSISTENT ? ConfigEnums.ZoomModes.PERSISTENT : ConfigEnums.ZoomModes.HOLD), Map.entry(OkZoomerConfigManager.CONFIG.features.zoomScrolling, switch (preset) { case CLASSIC, SPYGLASS -> false; @@ -274,12 +279,12 @@ public void resetToPreset(ConfigEnums.ZoomPresets preset) { Map.entry(OkZoomerConfigManager.CONFIG.features.zoomOverlay, preset == ConfigEnums.ZoomPresets.SPYGLASS ? ConfigEnums.ZoomOverlays.SPYGLASS : ConfigEnums.ZoomOverlays.OFF), Map.entry(OkZoomerConfigManager.CONFIG.features.spyglassMode, preset == ConfigEnums.ZoomPresets.SPYGLASS ? ConfigEnums.SpyglassMode.BOTH : ConfigEnums.SpyglassMode.OFF), Map.entry(OkZoomerConfigManager.CONFIG.zoomValues.zoomDivisor, switch (preset) { - case PERSISTENT -> 1.0D; - case SPYGLASS -> 10.0D; - default -> 4.0D; + case PERSISTENT -> 1.0; + case SPYGLASS -> 10.0; + default -> 4.0; }), - Map.entry(OkZoomerConfigManager.CONFIG.zoomValues.minimumZoomDivisor, 1.0D), - Map.entry(OkZoomerConfigManager.CONFIG.zoomValues.maximumZoomDivisor, 50.0D), + Map.entry(OkZoomerConfigManager.CONFIG.zoomValues.minimumZoomDivisor, 1.0), + Map.entry(OkZoomerConfigManager.CONFIG.zoomValues.maximumZoomDivisor, 50.0), Map.entry(OkZoomerConfigManager.CONFIG.zoomValues.upperScrollSteps, switch (preset) { case PERSISTENT -> 38; case SPYGLASS -> 16; @@ -290,14 +295,10 @@ public void resetToPreset(ConfigEnums.ZoomPresets preset) { case SPYGLASS -> 8; default -> 4; }), - Map.entry(OkZoomerConfigManager.CONFIG.transitionValues.smoothTransitionFactor, switch (preset) { - case CLASSIC_ZOOMER -> 0.75; - case SPYGLASS -> 0.5; - default -> 0.6; - }), - Map.entry(OkZoomerConfigManager.CONFIG.zoomValues.cinematicMultiplier, 4.0D), - Map.entry(OkZoomerConfigManager.CONFIG.transitionValues.minimumLinearStep, 0.16D), - Map.entry(OkZoomerConfigManager.CONFIG.transitionValues.maximumLinearStep, 0.22D), + Map.entry(OkZoomerConfigManager.CONFIG.transitionValues.smoothTransitionFactor, preset == ConfigEnums.ZoomPresets.SPYGLASS ? 0.5 : 0.6), + Map.entry(OkZoomerConfigManager.CONFIG.zoomValues.cinematicMultiplier, 4.0), + Map.entry(OkZoomerConfigManager.CONFIG.transitionValues.minimumLinearStep, 0.16), + Map.entry(OkZoomerConfigManager.CONFIG.transitionValues.maximumLinearStep, 0.22), Map.entry(OkZoomerConfigManager.CONFIG.tweaks.resetZoomWithMouse, preset != ConfigEnums.ZoomPresets.CLASSIC), Map.entry(OkZoomerConfigManager.CONFIG.tweaks.hideCrosshair, preset == ConfigEnums.ZoomPresets.DEFAULT), Map.entry(OkZoomerConfigManager.CONFIG.tweaks.forgetZoomDivisor, true), diff --git a/src/main/java/io/github/ennuil/ok_zoomer/mixin/common/GameRendererMixin.java b/src/main/java/io/github/ennuil/ok_zoomer/mixin/common/GameRendererMixin.java index fcf2086..579aea7 100644 --- a/src/main/java/io/github/ennuil/ok_zoomer/mixin/common/GameRendererMixin.java +++ b/src/main/java/io/github/ennuil/ok_zoomer/mixin/common/GameRendererMixin.java @@ -1,7 +1,9 @@ package io.github.ennuil.ok_zoomer.mixin.common; +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.llamalad7.mixinextras.sugar.Local; import com.llamalad7.mixinextras.sugar.ref.LocalDoubleRef; +import io.github.ennuil.ok_zoomer.config.OkZoomerConfigManager; import io.github.ennuil.ok_zoomer.zoom.Zoom; import net.minecraft.client.Camera; import net.minecraft.client.renderer.GameRenderer; @@ -47,4 +49,13 @@ private void getZoomedFov(Camera activeRenderInfo, float partialTicks, boolean u internalFov.set(zoomedFov); } + + @ModifyExpressionValue(method = "bobView", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Mth;lerp(FFF)F")) + private float modifyBob(float bob, @Local(argsOnly = true) float delta) { + if (!Zoom.isZooming() || !OkZoomerConfigManager.CONFIG.features.reduceViewBobbing.value()) { + return bob; + } else { + return (float) Zoom.getTransitionMode().applyZoom(bob, delta); + } + } } diff --git a/src/main/java/io/github/ennuil/ok_zoomer/mixin/common/GuiMixin.java b/src/main/java/io/github/ennuil/ok_zoomer/mixin/common/GuiMixin.java index bf59685..676dcf5 100644 --- a/src/main/java/io/github/ennuil/ok_zoomer/mixin/common/GuiMixin.java +++ b/src/main/java/io/github/ennuil/ok_zoomer/mixin/common/GuiMixin.java @@ -99,7 +99,7 @@ private void hideCrosshair(GuiGraphics graphics, DeltaTracker deltaTracker, Oper original.call(graphics, deltaTracker); } else { float fade = 1.0F - (float) Zoom.getTransitionMode().getFade(deltaTracker.getGameTimeDeltaPartialTick(true)); - RenderSystem.setShaderColor(fade, fade, fade, 1.0F); + RenderSystem.setShaderColor(fade, fade, fade, fade); original.call(graphics, deltaTracker); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); } diff --git a/src/main/resources/assets/ok_zoomer/lang/en_us.json b/src/main/resources/assets/ok_zoomer/lang/en_us.json index 2b3d3cb..f53e948 100644 --- a/src/main/resources/assets/ok_zoomer/lang/en_us.json +++ b/src/main/resources/assets/ok_zoomer/lang/en_us.json @@ -17,6 +17,8 @@ "config.ok_zoomer.features.zoom_transition.smooth.tooltip": "The zoom will smoothly transition between its on and off states in a manner resembling the game's FOV transitions.", "config.ok_zoomer.features.zoom_transition.linear": "Linear", "config.ok_zoomer.features.zoom_transition.linear.tooltip": "The zoom will linearly transition between its on and off states.", + "config.ok_zoomer.features.reduce_view_bobbing": "Reduce View Bobbing", + "config.ok_zoomer.features.reduce_view_bobbing.tooltip": "Divides the amount of view bobbing with the zoom divisor while zooming.", "config.ok_zoomer.features.zoom_mode": "Zoom Mode", "config.ok_zoomer.features.zoom_mode.hold": "Hold", "config.ok_zoomer.features.zoom_mode.hold.tooltip": "The zoom will require the zoom key to be held.", @@ -86,7 +88,7 @@ "config.ok_zoomer.presets.preset.default": "Default", "config.ok_zoomer.presets.preset.default.tooltip": "Reset to the default settings.", "config.ok_zoomer.presets.preset.classic_zoomer": "Classic Zoomer", - "config.ok_zoomer.presets.preset.classic_zoomer.tooltip": "Reset to the old default settings, featuring a faster smooth transition factor.", + "config.ok_zoomer.presets.preset.classic_zoomer.tooltip": "Reset to this mod's old default settings.", "config.ok_zoomer.presets.preset.classic": "Classic", "config.ok_zoomer.presets.preset.classic.tooltip": "Reset to a preset that emulates the OptiFine zoom.", "config.ok_zoomer.presets.preset.persistent": "Persistent", diff --git a/src/main/resources/assets/ok_zoomer/lang/pt_br.json b/src/main/resources/assets/ok_zoomer/lang/pt_br.json index 49ee2b7..d883cc5 100644 --- a/src/main/resources/assets/ok_zoomer/lang/pt_br.json +++ b/src/main/resources/assets/ok_zoomer/lang/pt_br.json @@ -18,6 +18,8 @@ "config.ok_zoomer.features.zoom_transition.smooth.tooltip": "O zoom transitará entre os estados ativo e desativo de forma suave, semelhante às transições do campo de visão do jogo.", "config.ok_zoomer.features.zoom_transition.linear": "Linear", "config.ok_zoomer.features.zoom_transition.linear.tooltip": "O zoom transitará entre os estados ativo e desativo de forma linear.", + "config.ok_zoomer.features.reduce_view_bobbing": "Reduzir balanço", + "config.ok_zoomer.features.reduce_view_bobbing.tooltip": "Divide a intensidade do balanço de visão com o divisor de zoom durante o zoom.", "config.ok_zoomer.features.zoom_mode": "Modo do zoom", "config.ok_zoomer.features.zoom_mode.hold": "Segurar", "config.ok_zoomer.features.zoom_mode.hold.tooltip": "O zoom irá depender da tecla do zoom ser segurado.", @@ -87,7 +89,7 @@ "config.ok_zoomer.presets.preset.default": "Padrão", "config.ok_zoomer.presets.preset.default.tooltip": "Redefine para as definições padrões.", "config.ok_zoomer.presets.preset.classic_zoomer": "Zoomer clássico", - "config.ok_zoomer.presets.preset.classic_zoomer.tooltip": "Redefine para as definições padrões antigos, apresentando um fator de transição suave rápido.", + "config.ok_zoomer.presets.preset.classic_zoomer.tooltip": "Redefine para as definições padrões antigas desse mod.", "config.ok_zoomer.presets.preset.classic": "Clássica", "config.ok_zoomer.presets.preset.classic.tooltip": "Redefine para uma predefinição que emula o zoom do OptiFine.", "config.ok_zoomer.presets.preset.persistent": "Persistente",