diff --git a/common/src/main/java/io/github/ennuil/ok_zoomer/config/ConfigEnums.java b/common/src/main/java/io/github/ennuil/ok_zoomer/config/ConfigEnums.java index 3017b347..592ddfac 100644 --- a/common/src/main/java/io/github/ennuil/ok_zoomer/config/ConfigEnums.java +++ b/common/src/main/java/io/github/ennuil/ok_zoomer/config/ConfigEnums.java @@ -19,19 +19,30 @@ public enum ZoomModes implements ConfigEnum { PERSISTENT } + public enum ScrollingModes implements ConfigEnum { + EXPONENTIAL, + LEGACY + } + public enum ZoomOverlays implements ConfigEnum { OFF, VIGNETTE, SPYGLASS } - public enum SpyglassMode implements ConfigEnum { + public enum SpyglassModes implements ConfigEnum { OFF, REQUIRE_ITEM, REPLACE_ZOOM, BOTH } + public enum SeeDistantEntitiesModes implements ConfigEnum { + OFF, + SAFE, + ON + } + public enum ZoomPresets implements ConfigEnum { CAMERA, COMPETITIVE, diff --git a/common/src/main/java/io/github/ennuil/ok_zoomer/config/OkZoomerConfig.java b/common/src/main/java/io/github/ennuil/ok_zoomer/config/OkZoomerConfig.java index 0915b0fb..8af2e8c0 100644 --- a/common/src/main/java/io/github/ennuil/ok_zoomer/config/OkZoomerConfig.java +++ b/common/src/main/java/io/github/ennuil/ok_zoomer/config/OkZoomerConfig.java @@ -13,11 +13,12 @@ public class OkZoomerConfig extends ReflectiveConfig { @Comment("Allows for configuring the main zoom features.") public final FeaturesConfig features = new FeaturesConfig(); - @Alias("values") @Comment("Allows for precise tweaking of the zoom.") public final ZoomValuesConfig zoomValues = new ZoomValuesConfig(); - @Alias("values") + @Comment("Allows to configure the \"Legacy\" scrolling mode.") + public final LegacyScrollValuesConfig legacyScrollValues = new LegacyScrollValuesConfig(); + @Comment("Allows for precise tweaking of zoom transitions.") public final TransitionValuesConfig transitionValues = new TransitionValuesConfig(); @@ -61,6 +62,13 @@ public static class FeaturesConfig extends Section { @Comment("Allows to increase or decrease the zoom by scrolling with the mouse wheel.") public final TrackedValue zoomScrolling = this.value(true); + @WidgetSize(Size.HALF) + @Comment(""" + "EXPONENTIAL": The zoom will scroll in an exponential way, making zoom steps consistent. This may be harder to configure currently. + "LEGACY": The zoom will scroll in an arbitrary way. This may be easier to configure currently, but scrolling may feel harder on higher zoom levels. + """) + public final TrackedValue scrollingMode = this.value(ScrollingModes.EXPONENTIAL); + @WidgetSize(Size.HALF) @Comment("Retains the interface when zooming.") public final TrackedValue persistentInterface = this.value(false); @@ -85,10 +93,37 @@ public static class FeaturesConfig extends Section { "REPLACE_ZOOM": Zooming will replace the spyglass zoom but it won't require one in order to work. "BOTH": Zooming will act as a complete replacement of the spyglass zoom, requiring one to work and replacing its zoom as well. """) - public final TrackedValue spyglassMode = this.value(SpyglassMode.OFF); + public final TrackedValue spyglassMode = this.value(SpyglassModes.OFF); } public static class ZoomValuesConfig extends Section { + @WidgetSize(Size.HALF) + @Comment("Determines the number to be used on the exponential curve. If unsure, keep this value at 2.") + @IntegerRange(min = 2, max = Integer.MAX_VALUE) + public final TrackedValue scrollBase = this.value(2); + + @WidgetSize(Size.HALF) + @Comment("Determines the resolution of zoom scrolling. This will effectively multiply the amount of scroll steps.") + @IntegerRange(min = 1, max = Integer.MAX_VALUE) + public final TrackedValue scrollResolution = this.value(5); + + @WidgetSize(Size.HALF) + @Comment("The default scroll step to use on zooming in.") + @IntegerRange(min = 0, max = Integer.MAX_VALUE) + public final TrackedValue defaultScrollStep = this.value(10); + + @WidgetSize(Size.HALF) + @Comment("The maximum amount of scroll steps that the zoom may reach.") + @IntegerRange(min = 0, max = Integer.MAX_VALUE) + public final TrackedValue scrollStepLimit = this.value(30); + + @WidgetSize(Size.HALF) + @Comment("The multiplier used by the multiplied cinematic camera.") + @FloatRange(min = Double.MIN_NORMAL, max = 32.0) + public final TrackedValue cinematicMultiplier = this.value(4.0); + } + + public static class LegacyScrollValuesConfig extends Section { @WidgetSize(Size.HALF) @Comment("The divisor used to apply zoom to the FOV. A higher value means more zoom.") @FloatRange(min = Double.MIN_NORMAL, max = Double.MAX_VALUE) @@ -113,11 +148,6 @@ public static class ZoomValuesConfig extends Section { @Comment("The number of steps between the zoom divisor and the maximum zoom divisor. Used by zoom scrolling.") @IntegerRange(min = 0, max = Integer.MAX_VALUE) public final TrackedValue upperScrollSteps = this.value(10); - - @WidgetSize(Size.HALF) - @Comment("The multiplier used for the multiplied cinematic camera.") - @FloatRange(min = Double.MIN_NORMAL, max = 32.0) - public final TrackedValue cinematicMultiplier = this.value(4.0); } public static class TransitionValuesConfig extends Section { @@ -128,14 +158,9 @@ public static class TransitionValuesConfig extends Section { public final TrackedValue smoothTransitionFactor = this.value(0.6); @WidgetSize(Size.HALF) - @Comment("The minimum value which the linear zoom transition step can reach.") + @Comment("The value which the linear zoom transition step can reach.") @FloatRange(min = 0.0, max = Double.MAX_VALUE) - public final TrackedValue minimumLinearStep = this.value(0.16); - - @WidgetSize(Size.HALF) - @Comment("The maximum value which the linear zoom transition step can reach.") - @FloatRange(min = 0.0, max = Double.MAX_VALUE) - public final TrackedValue maximumLinearStep = this.value(0.22); + public final TrackedValue linearStep = this.value(0.2); } public static class TweaksConfig extends Section { @@ -152,9 +177,13 @@ public static class TweaksConfig extends Section { public final TrackedValue resetZoomWithMouse = this.value(true); @WidgetSize(Size.HALF) - @Comment("Improves performance by making the game render less of the world while zoomed in. This feature requires the Sodium mod in order to work.") + @Comment("Improves performance by making the game render less of the world while zoomed in. This feature depends on the Sodium mod in order to work.") public final TrackedValue smartOcclusion = this.value(true); + @WidgetSize(Size.HALF) + @Comment("Expands the entity distance while zooming in, allowing creatures and certain blocks to be seen from afar. This may have a performance impact during zoom.") + public final TrackedValue seeDistantEntities = this.value(SeeDistantEntitiesModes.SAFE); + @WidgetSize(Size.HALF) @Comment("If enabled, the current zoom divisor is forgotten once zooming is finished.") public final TrackedValue forgetZoomDivisor = this.value(true); @@ -163,6 +192,10 @@ public static class TweaksConfig extends Section { @Comment("If enabled, the zoom will use spyglass sounds on zooming in and out.") public final TrackedValue useSpyglassSounds = this.value(false); + @WidgetSize(Size.HALF) + @Comment("Displays debug information for exponential zoom scrolling. Currently it may help with configuring the zoom scrolling.") + public final TrackedValue debugScrolling = this.value(false); + // TODO - Disable it upon stable release! @WidgetSize(Size.HALF) @Comment("Prints a random owo in the console when the game starts.") diff --git a/common/src/main/java/io/github/ennuil/ok_zoomer/config/OkZoomerConfigManager.java b/common/src/main/java/io/github/ennuil/ok_zoomer/config/OkZoomerConfigManager.java index 1c8a7301..fa1bca51 100644 --- a/common/src/main/java/io/github/ennuil/ok_zoomer/config/OkZoomerConfigManager.java +++ b/common/src/main/java/io/github/ennuil/ok_zoomer/config/OkZoomerConfigManager.java @@ -1,18 +1,18 @@ package io.github.ennuil.ok_zoomer.config; +import io.github.ennuil.ok_zoomer.config.ConfigEnums.CinematicCameraOptions; +import io.github.ennuil.ok_zoomer.utils.ModUtils; +import io.github.ennuil.ok_zoomer.wrench_wrapper.WrenchWrapper; import io.github.ennuil.ok_zoomer.zoom.Zoom; import io.github.ennuil.ok_zoomer.zoom.modifiers.CinematicCameraMouseModifier; import io.github.ennuil.ok_zoomer.zoom.modifiers.ContainingMouseModifier; +import io.github.ennuil.ok_zoomer.zoom.modifiers.MultipliedCinematicCameraMouseModifier; import io.github.ennuil.ok_zoomer.zoom.modifiers.ZoomDivisorMouseModifier; import io.github.ennuil.ok_zoomer.zoom.overlays.SpyglassZoomOverlay; +import io.github.ennuil.ok_zoomer.zoom.overlays.ZoomerZoomOverlay; import io.github.ennuil.ok_zoomer.zoom.transitions.InstantTransitionMode; -import io.github.ennuil.ok_zoomer.zoom.transitions.SmoothTransitionMode; -import io.github.ennuil.ok_zoomer.config.ConfigEnums.CinematicCameraOptions; -import io.github.ennuil.ok_zoomer.utils.ModUtils; -import io.github.ennuil.ok_zoomer.wrench_wrapper.WrenchWrapper; import io.github.ennuil.ok_zoomer.zoom.transitions.LinearTransitionMode; -import io.github.ennuil.ok_zoomer.zoom.modifiers.MultipliedCinematicCameraMouseModifier; -import io.github.ennuil.ok_zoomer.zoom.overlays.ZoomerZoomOverlay; +import io.github.ennuil.ok_zoomer.zoom.transitions.SmoothTransitionMode; import net.minecraft.resources.ResourceLocation; public class OkZoomerConfigManager { @@ -30,16 +30,13 @@ public static void configureZoomInstance() { Zoom.setTransitionMode( switch (CONFIG.features.zoomTransition.value()) { case SMOOTH -> new SmoothTransitionMode(CONFIG.transitionValues.smoothTransitionFactor.value().floatValue()); - case LINEAR -> new LinearTransitionMode(CONFIG.transitionValues.minimumLinearStep.value(), CONFIG.transitionValues.maximumLinearStep.value()); + case LINEAR -> new LinearTransitionMode(CONFIG.transitionValues.linearStep.value()); default -> new InstantTransitionMode(); } ); - // Sets zoom divisor - Zoom.setDefaultZoomDivisor(CONFIG.zoomValues.zoomDivisor.value()); - // Sets mouse modifier - configureZoomModifier(); + OkZoomerConfigManager.configureZoomModifier(); // Sets zoom overlay // TODO - Restore the "Use Spyglass Texture" option as a "Use Custom Texture" option diff --git a/common/src/main/java/io/github/ennuil/ok_zoomer/config/screen/ZoomPresets.java b/common/src/main/java/io/github/ennuil/ok_zoomer/config/screen/ZoomPresets.java index cbb5ff98..c6cafd33 100644 --- a/common/src/main/java/io/github/ennuil/ok_zoomer/config/screen/ZoomPresets.java +++ b/common/src/main/java/io/github/ennuil/ok_zoomer/config/screen/ZoomPresets.java @@ -29,9 +29,7 @@ public class ZoomPresets { public static final Map, Object> PERSISTENT = Map.of( OkZoomerConfigManager.CONFIG.features.zoomMode, ConfigEnums.ZoomModes.PERSISTENT, OkZoomerConfigManager.CONFIG.features.persistentInterface, true, - OkZoomerConfigManager.CONFIG.zoomValues.zoomDivisor, 1.0, - OkZoomerConfigManager.CONFIG.zoomValues.lowerScrollSteps, 0, - OkZoomerConfigManager.CONFIG.zoomValues.upperScrollSteps, 38, + OkZoomerConfigManager.CONFIG.zoomValues.defaultScrollStep, 0, OkZoomerConfigManager.CONFIG.tweaks.hideCrosshair, false ); @@ -40,10 +38,14 @@ public class ZoomPresets { Map.entry(OkZoomerConfigManager.CONFIG.features.zoomScrolling, false), Map.entry(OkZoomerConfigManager.CONFIG.features.persistentInterface, true), Map.entry(OkZoomerConfigManager.CONFIG.features.zoomOverlay, ConfigEnums.ZoomOverlays.SPYGLASS), - Map.entry(OkZoomerConfigManager.CONFIG.features.spyglassMode, ConfigEnums.SpyglassMode.BOTH), - Map.entry(OkZoomerConfigManager.CONFIG.zoomValues.zoomDivisor, 10.0), - Map.entry(OkZoomerConfigManager.CONFIG.zoomValues.lowerScrollSteps, 8), - Map.entry(OkZoomerConfigManager.CONFIG.zoomValues.upperScrollSteps, 16), + Map.entry(OkZoomerConfigManager.CONFIG.features.spyglassMode, ConfigEnums.SpyglassModes.BOTH), + Map.entry(OkZoomerConfigManager.CONFIG.zoomValues.scrollBase, 10), + Map.entry(OkZoomerConfigManager.CONFIG.zoomValues.scrollResolution, 10), + Map.entry(OkZoomerConfigManager.CONFIG.zoomValues.defaultScrollStep, 10), + Map.entry(OkZoomerConfigManager.CONFIG.zoomValues.scrollStepLimit, 20), + Map.entry(OkZoomerConfigManager.CONFIG.legacyScrollValues.zoomDivisor, 10.0), + Map.entry(OkZoomerConfigManager.CONFIG.legacyScrollValues.lowerScrollSteps, 8), + Map.entry(OkZoomerConfigManager.CONFIG.legacyScrollValues.upperScrollSteps, 16), Map.entry(OkZoomerConfigManager.CONFIG.transitionValues.smoothTransitionFactor, 0.5), Map.entry(OkZoomerConfigManager.CONFIG.tweaks.hideCrosshair, false), Map.entry(OkZoomerConfigManager.CONFIG.tweaks.useSpyglassSounds, true) diff --git a/common/src/main/java/io/github/ennuil/ok_zoomer/events/ManageExtraKeysEvent.java b/common/src/main/java/io/github/ennuil/ok_zoomer/events/ManageExtraKeysEvent.java index d8b32502..4167fa67 100644 --- a/common/src/main/java/io/github/ennuil/ok_zoomer/events/ManageExtraKeysEvent.java +++ b/common/src/main/java/io/github/ennuil/ok_zoomer/events/ManageExtraKeysEvent.java @@ -12,11 +12,11 @@ public static void startClientTick(Minecraft minecraft) { if (!OkZoomerConfigManager.CONFIG.features.extraKeyBinds.value()) return; if (ZoomKeyBinds.DECREASE_ZOOM_KEY.isDown() && !ZoomKeyBinds.INCREASE_ZOOM_KEY.isDown()) { - ZoomUtils.changeZoomDivisor(minecraft, false); + ZoomUtils.changeZoomDivisor(false); } if (ZoomKeyBinds.INCREASE_ZOOM_KEY.isDown() && !ZoomKeyBinds.DECREASE_ZOOM_KEY.isDown()) { - ZoomUtils.changeZoomDivisor(minecraft, true); + ZoomUtils.changeZoomDivisor(true); } if (ZoomKeyBinds.RESET_ZOOM_KEY.isDown()) { diff --git a/common/src/main/java/io/github/ennuil/ok_zoomer/mixin/common/BlockEntityRendererMixin.java b/common/src/main/java/io/github/ennuil/ok_zoomer/mixin/common/BlockEntityRendererMixin.java new file mode 100644 index 00000000..bdeaeed7 --- /dev/null +++ b/common/src/main/java/io/github/ennuil/ok_zoomer/mixin/common/BlockEntityRendererMixin.java @@ -0,0 +1,21 @@ +package io.github.ennuil.ok_zoomer.mixin.common; + +import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import io.github.ennuil.ok_zoomer.utils.ZoomUtils; +import io.github.ennuil.ok_zoomer.zoom.Zoom; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; +import net.minecraft.util.Mth; +import org.spongepowered.asm.mixin.Mixin; + +@Mixin(BlockEntityRenderer.class) +public interface BlockEntityRendererMixin { + @WrapMethod(method = "getViewDistance") + private int modifyBlockEntityViewDistance(Operation original) { + if (!ZoomUtils.canSeeDistantEntities()) { + return original.call(); + } else { + return original.call() * (Zoom.isZooming() ? Math.max(1, Mth.ceil(Zoom.getZoomDivisor())) : 1); + } + } +} diff --git a/common/src/main/java/io/github/ennuil/ok_zoomer/mixin/common/GameRendererMixin.java b/common/src/main/java/io/github/ennuil/ok_zoomer/mixin/common/GameRendererMixin.java index acad8266..38278fb9 100644 --- a/common/src/main/java/io/github/ennuil/ok_zoomer/mixin/common/GameRendererMixin.java +++ b/common/src/main/java/io/github/ennuil/ok_zoomer/mixin/common/GameRendererMixin.java @@ -42,7 +42,7 @@ private int modifyCulling(int original) { if (!Zoom.isZooming() || !ZoomUtils.hasSmartOcclusion()) { return original; } else { - return Mth.positiveCeilDiv(original, Mth.floor(Zoom.getZoomDivisor())); + return Mth.positiveCeilDiv(original, Math.max(1, Mth.floor(Zoom.getZoomDivisor()))); } } diff --git a/common/src/main/java/io/github/ennuil/ok_zoomer/mixin/common/IntegratedServerMixin.java b/common/src/main/java/io/github/ennuil/ok_zoomer/mixin/common/IntegratedServerMixin.java new file mode 100644 index 00000000..bd918754 --- /dev/null +++ b/common/src/main/java/io/github/ennuil/ok_zoomer/mixin/common/IntegratedServerMixin.java @@ -0,0 +1,21 @@ +package io.github.ennuil.ok_zoomer.mixin.common; + +import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import io.github.ennuil.ok_zoomer.utils.ZoomUtils; +import io.github.ennuil.ok_zoomer.zoom.Zoom; +import net.minecraft.client.server.IntegratedServer; +import net.minecraft.util.Mth; +import org.spongepowered.asm.mixin.Mixin; + +@Mixin(IntegratedServer.class) +public abstract class IntegratedServerMixin { + @WrapMethod(method = "getScaledTrackingDistance") + private int modifyEntityViewDistance(int trackingDistance, Operation original) { + if (!ZoomUtils.canSeeDistantEntities()) { + return original.call(trackingDistance); + } else { + return original.call(trackingDistance * (Zoom.isZooming() ? Math.max(1, Mth.ceil(Zoom.getZoomDivisor())) : 1)); + } + } +} diff --git a/common/src/main/java/io/github/ennuil/ok_zoomer/mixin/common/LevelRendererMixin.java b/common/src/main/java/io/github/ennuil/ok_zoomer/mixin/common/LevelRendererMixin.java new file mode 100644 index 00000000..4872993f --- /dev/null +++ b/common/src/main/java/io/github/ennuil/ok_zoomer/mixin/common/LevelRendererMixin.java @@ -0,0 +1,26 @@ +package io.github.ennuil.ok_zoomer.mixin.common; + +import io.github.ennuil.ok_zoomer.utils.ZoomUtils; +import io.github.ennuil.ok_zoomer.zoom.Zoom; +import net.minecraft.client.renderer.LevelRenderer; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyArg; + +@Mixin(LevelRenderer.class) +public abstract class LevelRendererMixin { + @ModifyArg( + method = "collectVisibleEntities", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/entity/Entity;setViewScale(D)V" + ) + ) + private double modifyViewScale(double original) { + if (!ZoomUtils.canSeeDistantEntities()) { + return original; + } else { + return original * Math.max(1.0, Zoom.isZooming() ? Zoom.getZoomDivisor() : 1.0); + } + } +} diff --git a/common/src/main/java/io/github/ennuil/ok_zoomer/mixin/common/MouseHandlerMixin.java b/common/src/main/java/io/github/ennuil/ok_zoomer/mixin/common/MouseHandlerMixin.java index 95faf272..3678d883 100644 --- a/common/src/main/java/io/github/ennuil/ok_zoomer/mixin/common/MouseHandlerMixin.java +++ b/common/src/main/java/io/github/ennuil/ok_zoomer/mixin/common/MouseHandlerMixin.java @@ -20,10 +20,6 @@ // This mixin is responsible for the mouse-behavior-changing part of the zoom @Mixin(MouseHandler.class) public abstract class MouseHandlerMixin { - @Shadow - @Final - private Minecraft minecraft; - // Handles zoom scrolling @Inject( method = "onScroll", @@ -38,7 +34,7 @@ private void zoomerOnMouseScroll(CallbackInfo ci, @Local int k) { } if (Zoom.isZooming()) { - ZoomUtils.changeZoomDivisor(this.minecraft, k > 0); + ZoomUtils.changeZoomDivisor(k > 0); ci.cancel(); } } diff --git a/common/src/main/java/io/github/ennuil/ok_zoomer/utils/ZoomUtils.java b/common/src/main/java/io/github/ennuil/ok_zoomer/utils/ZoomUtils.java index 5f2c1ad4..a8a0a9cf 100644 --- a/common/src/main/java/io/github/ennuil/ok_zoomer/utils/ZoomUtils.java +++ b/common/src/main/java/io/github/ennuil/ok_zoomer/utils/ZoomUtils.java @@ -1,6 +1,7 @@ package io.github.ennuil.ok_zoomer.utils; import com.mojang.blaze3d.platform.InputConstants; +import io.github.ennuil.ok_zoomer.config.ConfigEnums; import io.github.ennuil.ok_zoomer.config.OkZoomerConfigManager; import io.github.ennuil.ok_zoomer.key_binds.ZoomKeyBinds; import io.github.ennuil.ok_zoomer.zoom.Zoom; @@ -10,7 +11,6 @@ import net.minecraft.client.player.LocalPlayer; import net.minecraft.core.registries.Registries; import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagKey; import net.minecraft.util.Mth; import net.minecraft.world.item.Item; @@ -26,7 +26,7 @@ public class ZoomUtils { public static final SystemToast.SystemToastId TOAST_ID = new SystemToast.SystemToastId(); - public static final TagKey ZOOM_DEPENDENCIES_TAG = TagKey.create(Registries.ITEM, ZoomUtils.id("zoom_dependencies")); + public static final TagKey ZOOM_DEPENDENCIES_TAG = TagKey.create(Registries.ITEM, ModUtils.id("zoom_dependencies")); public static int zoomStep = 0; @@ -34,21 +34,42 @@ public class ZoomUtils { private static boolean safeSmartOcclusion = false; // The method used for changing the zoom divisor, used by zoom scrolling and the key binds - public static void changeZoomDivisor(Minecraft minecraft, boolean increase) { - double zoomDivisor = OkZoomerConfigManager.CONFIG.zoomValues.zoomDivisor.value(); - double minimumZoomDivisor = OkZoomerConfigManager.CONFIG.zoomValues.minimumZoomDivisor.value(); - double maximumZoomDivisor = OkZoomerConfigManager.CONFIG.zoomValues.maximumZoomDivisor.value(); - int upperScrollStep = OkZoomerConfigManager.CONFIG.zoomValues.upperScrollSteps.value(); - int lowerScrollStep = OkZoomerConfigManager.CONFIG.zoomValues.lowerScrollSteps.value(); - - zoomStep = increase ? Math.min(zoomStep + 1, upperScrollStep) : Math.max(zoomStep - 1, -lowerScrollStep); - - if (zoomStep > 0) { - Zoom.setZoomDivisor(zoomDivisor + ((maximumZoomDivisor - zoomDivisor) / upperScrollStep * zoomStep)); - } else if (zoomStep == 0) { - Zoom.setZoomDivisor(zoomDivisor); + public static void changeZoomDivisor(boolean increase) { + if (OkZoomerConfigManager.CONFIG.features.scrollingMode.value() == ConfigEnums.ScrollingModes.EXPONENTIAL) { + int scrollBase = OkZoomerConfigManager.CONFIG.zoomValues.scrollBase.value(); + int scrollResolution = OkZoomerConfigManager.CONFIG.zoomValues.scrollResolution.value(); + int upperScrollStep = OkZoomerConfigManager.CONFIG.zoomValues.scrollStepLimit.value(); + int lowerScrollStep = 0; + + zoomStep = increase ? Math.min(zoomStep + 1, upperScrollStep) : Math.max(zoomStep - 1, -lowerScrollStep); + + double divisor = 1.0; + if (zoomStep != 0) { + divisor = Math.pow(scrollBase, (double) zoomStep / scrollResolution); + Zoom.setZoomDivisor(divisor); + } else { + Zoom.setZoomDivisor(1); + } + + if (OkZoomerConfigManager.CONFIG.tweaks.debugScrolling.value()) { + Minecraft.getInstance().player.displayClientMessage(Component.literal( zoomStep + " - " + divisor), true); + } } else { - Zoom.setZoomDivisor(zoomDivisor + ((minimumZoomDivisor - zoomDivisor) / lowerScrollStep * -zoomStep)); + double zoomDivisor = OkZoomerConfigManager.CONFIG.legacyScrollValues.zoomDivisor.value(); + double minimumZoomDivisor = OkZoomerConfigManager.CONFIG.legacyScrollValues.minimumZoomDivisor.value(); + double maximumZoomDivisor = OkZoomerConfigManager.CONFIG.legacyScrollValues.maximumZoomDivisor.value(); + int upperScrollStep = OkZoomerConfigManager.CONFIG.legacyScrollValues.upperScrollSteps.value(); + int lowerScrollStep = OkZoomerConfigManager.CONFIG.legacyScrollValues.lowerScrollSteps.value(); + + zoomStep = increase ? Math.min(zoomStep + 1, upperScrollStep) : Math.max(zoomStep - 1, -lowerScrollStep); + + if (zoomStep > 0) { + Zoom.setZoomDivisor(zoomDivisor + ((maximumZoomDivisor - zoomDivisor) / upperScrollStep * zoomStep)); + } else if (zoomStep == 0) { + Zoom.setZoomDivisor(zoomDivisor); + } else { + Zoom.setZoomDivisor(zoomDivisor + ((minimumZoomDivisor - zoomDivisor) / lowerScrollStep * -zoomStep)); + } } } @@ -56,13 +77,21 @@ public static void changeZoomDivisor(Minecraft minecraft, boolean increase) { public static void resetZoomDivisor(boolean userPrompted) { if (!userPrompted && !OkZoomerConfigManager.CONFIG.tweaks.forgetZoomDivisor.value()) return; - Zoom.resetZoomDivisor(); - zoomStep = 0; + if (OkZoomerConfigManager.CONFIG.features.scrollingMode.value() == ConfigEnums.ScrollingModes.EXPONENTIAL) { + int scrollBase = OkZoomerConfigManager.CONFIG.zoomValues.scrollBase.value(); + int scrollResolution = OkZoomerConfigManager.CONFIG.zoomValues.scrollResolution.value(); + zoomStep = OkZoomerConfigManager.CONFIG.zoomValues.defaultScrollStep.value(); + Zoom.setZoomDivisor(Math.pow(scrollBase, (double) zoomStep / scrollResolution)); + } else { + zoomStep = 0; + Zoom.setZoomDivisor(OkZoomerConfigManager.CONFIG.legacyScrollValues.zoomDivisor.value()); + } } public static void keepZoomStepsWithinBounds() { - int upperScrollStep = OkZoomerConfigManager.CONFIG.zoomValues.upperScrollSteps.value(); - int lowerScrollStep = OkZoomerConfigManager.CONFIG.zoomValues.lowerScrollSteps.value(); + boolean isExponential = OkZoomerConfigManager.CONFIG.features.scrollingMode.value() == ConfigEnums.ScrollingModes.EXPONENTIAL; + int upperScrollStep = isExponential ? OkZoomerConfigManager.CONFIG.zoomValues.scrollStepLimit.value() : OkZoomerConfigManager.CONFIG.legacyScrollValues.upperScrollSteps.value(); + int lowerScrollStep = isExponential ? 0 : OkZoomerConfigManager.CONFIG.legacyScrollValues.lowerScrollSteps.value(); zoomStep = Mth.clamp(zoomStep, -lowerScrollStep, upperScrollStep); } @@ -93,16 +122,12 @@ public static void unbindConflictingKey(Minecraft client, boolean userPrompted) } } - public static ResourceLocation id(String path) { - return ModUtils.id(path); - } - public static boolean hasSpyglass(LocalPlayer player) { - return hasSpyglass.test(player); + return ZoomUtils.hasSpyglass.test(player); } public static void addSpyglassProvider(Predicate provider) { - hasSpyglass = hasSpyglass.or(provider); + ZoomUtils.hasSpyglass = ZoomUtils.hasSpyglass.or(provider); } public static void enableSafeSmartOcclusion() { @@ -112,4 +137,12 @@ public static void enableSafeSmartOcclusion() { public static boolean hasSmartOcclusion() { return OkZoomerConfigManager.CONFIG.tweaks.smartOcclusion.value() && ZoomUtils.safeSmartOcclusion; } + + public static boolean canSeeDistantEntities() { + return switch (OkZoomerConfigManager.CONFIG.tweaks.seeDistantEntities.value()) { + case SAFE -> ZoomUtils.safeSmartOcclusion; + case ON -> true; + case OFF -> false; + }; + } } diff --git a/common/src/main/java/io/github/ennuil/ok_zoomer/wrench_wrapper/WrenchWrapper.java b/common/src/main/java/io/github/ennuil/ok_zoomer/wrench_wrapper/WrenchWrapper.java index 448a848a..f80a1b5c 100644 --- a/common/src/main/java/io/github/ennuil/ok_zoomer/wrench_wrapper/WrenchWrapper.java +++ b/common/src/main/java/io/github/ennuil/ok_zoomer/wrench_wrapper/WrenchWrapper.java @@ -2,6 +2,7 @@ import org.jetbrains.annotations.NotNull; import org.quiltmc.config.api.ReflectiveConfig; +import org.quiltmc.config.implementor_api.ConfigEnvironment; import java.lang.reflect.InvocationTargetException; import java.util.Objects; @@ -24,6 +25,28 @@ public static C create(String family, String id, Cl } else { throw new IllegalStateException("Neither Quilt, Fabric nor NeoForge detected, cannot create Config Instance for %s!".formatted(configCreatorClass.getName())); } + } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + throw new IllegalStateException("How did you do this!!!!! " + e); + } + } + + public static ConfigEnvironment getConfigEnvironment() { + try { + if (WrenchWrapper.getClass("org.quiltmc.loader.api.QuiltLoader") != null) { + var clazz = Objects.requireNonNull(WrenchWrapper.getClass("io.github.ennuil.ok_zoomer.wrench_wrapper.quilt.QuiltWrapper")); + return (ConfigEnvironment) clazz.getMethod("getConfigEnvironment").invoke(null); + } else if (WrenchWrapper.getClass("net.fabricmc.loader.FabricLoader") != null + && WrenchWrapper.getClass("net.neoforged.neoforge.common.NeoForge") == null) { + // The above check immunizes Wrench Wrapper's wrapper against Sinytra Connector + var clazz = Objects.requireNonNull(WrenchWrapper.getClass("io.github.ennuil.ok_zoomer.wrench_wrapper.fabric.FabricWrapper")); + return (ConfigEnvironment) clazz.getMethod("getConfigEnvironment").invoke(null); + } else if (WrenchWrapper.getClass("net.neoforged.neoforge.common.NeoForge") != null) { + var clazz = Objects.requireNonNull(WrenchWrapper.getClass("io.github.ennuil.ok_zoomer.wrench_wrapper.norge.NorgeWrapper")); + return (ConfigEnvironment) clazz.getMethod("getConfigEnvironment").invoke(null); + } else { + throw new IllegalStateException("Neither Quilt, Fabric nor NeoForge detected, cannot get the Config Environment!"); + } } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { throw new IllegalStateException("How did you do this!!!!! " + e); } diff --git a/common/src/main/java/io/github/ennuil/ok_zoomer/zoom/Zoom.java b/common/src/main/java/io/github/ennuil/ok_zoomer/zoom/Zoom.java index d2de3fe9..7b9a6ac0 100644 --- a/common/src/main/java/io/github/ennuil/ok_zoomer/zoom/Zoom.java +++ b/common/src/main/java/io/github/ennuil/ok_zoomer/zoom/Zoom.java @@ -8,7 +8,6 @@ public class Zoom { private static boolean zooming = false; - private static double defaultZoomDivisor = 4.0F; private static double zoomDivisor = 4.0F; private static TransitionMode transitionMode = new SmoothTransitionMode(); private static MouseModifier mouseModifier = new ZoomDivisorMouseModifier(); @@ -22,14 +21,6 @@ public static void setZoomDivisor(double zoomDivisor) { Zoom.zoomDivisor = zoomDivisor; } - public static double getDefaultZoomDivisor() { - return Zoom.defaultZoomDivisor; - } - - public static void setDefaultZoomDivisor(double defaultZoomDivisor) { - Zoom.defaultZoomDivisor = defaultZoomDivisor; - } - public static boolean isZooming() { return Zoom.zooming; } @@ -38,10 +29,6 @@ public static void setZooming(boolean zooming) { Zoom.zooming = zooming; } - public static void resetZoomDivisor() { - Zoom.zoomDivisor = Zoom.defaultZoomDivisor; - } - public static TransitionMode getTransitionMode() { return transitionMode; } diff --git a/common/src/main/java/io/github/ennuil/ok_zoomer/zoom/transitions/LinearTransitionMode.java b/common/src/main/java/io/github/ennuil/ok_zoomer/zoom/transitions/LinearTransitionMode.java index e4dbff56..197dde57 100644 --- a/common/src/main/java/io/github/ennuil/ok_zoomer/zoom/transitions/LinearTransitionMode.java +++ b/common/src/main/java/io/github/ennuil/ok_zoomer/zoom/transitions/LinearTransitionMode.java @@ -5,17 +5,15 @@ // The implementation of the linear transition public class LinearTransitionMode implements TransitionMode { private boolean active; - private final double minimumLinearStep; - private final double maximumLinearStep; + private final double linearStep; private float internalMultiplier; private float lastInternalMultiplier; private float internalFade; private float lastInternalFade; - public LinearTransitionMode(double minimumLinearStep, double maximumLinearStep) { + public LinearTransitionMode(double linearStep) { this.active = false; - this.minimumLinearStep = minimumLinearStep; - this.maximumLinearStep = maximumLinearStep; + this.linearStep = linearStep; this.internalMultiplier = 1.0F; this.lastInternalMultiplier = 1.0F; this.internalFade = 0.0F; @@ -45,9 +43,8 @@ public void tick(boolean active, double divisor) { this.lastInternalMultiplier = this.internalMultiplier; this.lastInternalFade = this.internalFade; - double linearStep = Mth.clamp(zoomMultiplier, this.minimumLinearStep, this.maximumLinearStep); - this.internalMultiplier = Mth.approach(this.internalMultiplier, zoomMultiplier, (float) linearStep); - this.internalFade = Mth.approach(this.internalFade, fadeMultiplier, (float) linearStep); + this.internalMultiplier = Mth.approach(this.internalMultiplier, zoomMultiplier, (float) this.linearStep); + this.internalFade = Mth.approach(this.internalFade, fadeMultiplier, (float) this.linearStep); this.active = active; } diff --git a/common/src/main/resources/assets/ok_zoomer/lang/en_us.json b/common/src/main/resources/assets/ok_zoomer/lang/en_us.json index 6697da06..0ad496f6 100644 --- a/common/src/main/resources/assets/ok_zoomer/lang/en_us.json +++ b/common/src/main/resources/assets/ok_zoomer/lang/en_us.json @@ -29,6 +29,11 @@ "config.ok_zoomer.features.zoom_mode.persistent.tooltip": "The zoom will always be enabled, with the zoom key being used for zoom scrolling.", "config.ok_zoomer.features.zoom_scrolling": "Zoom Scrolling", "config.ok_zoomer.features.zoom_scrolling.tooltip": "Allows to increase or decrease the zoom by scrolling with the mouse wheel.", + "config.ok_zoomer.features.scrolling_mode": "Scrolling Mode", + "config.ok_zoomer.features.scrolling_mode.exponential": "Exponential", + "config.ok_zoomer.features.scrolling_mode.exponential.tooltip": "The zoom will scroll in an exponential way, making zoom steps consistent. This may be harder to configure currently.", + "config.ok_zoomer.features.scrolling_mode.legacy": "Legacy", + "config.ok_zoomer.features.scrolling_mode.legacy.tooltip": "The zoom will scroll in an arbitrary way. This may be easier to configure currently, but scrolling may feel harder on higher zoom levels.", "config.ok_zoomer.features.persistent_interface": "Persistent Interface", "config.ok_zoomer.features.persistent_interface.tooltip": "Retains the interface when zooming.", "config.ok_zoomer.features.extra_key_binds": "Extra Key Binds", @@ -50,25 +55,32 @@ "config.ok_zoomer.features.spyglass_mode.both": "Both", "config.ok_zoomer.features.spyglass_mode.both.tooltip": "Zooming will act as a complete replacement of the spyglass zoom, requiring one to work and replacing its zoom as well.", "config.ok_zoomer.zoom_values": "Zoom Values", - "config.ok_zoomer.zoom_values.zoom_divisor": "Zoom Divisor", - "config.ok_zoomer.zoom_values.zoom_divisor.tooltip": "The divisor used to apply zoom to the FOV. A higher value means more zoom.", - "config.ok_zoomer.zoom_values.minimum_zoom_divisor": "Minimum Zoom Divisor", - "config.ok_zoomer.zoom_values.minimum_zoom_divisor.tooltip": "The minimum zoom divisor that you can scroll down.", - "config.ok_zoomer.zoom_values.maximum_zoom_divisor": "Maximum Zoom Divisor", - "config.ok_zoomer.zoom_values.maximum_zoom_divisor.tooltip": "The maximum zoom divisor that you can scroll up.", - "config.ok_zoomer.zoom_values.lower_scroll_steps": "Lower Scroll Steps", - "config.ok_zoomer.zoom_values.lower_scroll_steps.tooltip": "The number of steps between the zoom divisor and the minimum zoom divisor. Used by zoom scrolling.", - "config.ok_zoomer.zoom_values.upper_scroll_steps": "Upper Scroll Steps", - "config.ok_zoomer.zoom_values.upper_scroll_steps.tooltip": "The number of steps between the zoom divisor and the maximum zoom divisor. Used by zoom scrolling.", + "config.ok_zoomer.zoom_values.scroll_base": "Scroll Base", + "config.ok_zoomer.zoom_values.scroll_base.tooltip": "Determines the number to be used on the exponential curve. If unsure, keep this value at 2.", + "config.ok_zoomer.zoom_values.scroll_resolution": "Scroll Resolution", + "config.ok_zoomer.zoom_values.scroll_resolution.tooltip": "Determines the resolution of zoom scrolling. This will effectively multiply the amount of scroll steps.", + "config.ok_zoomer.zoom_values.default_scroll_step": "Default Scroll Step", + "config.ok_zoomer.zoom_values.default_scroll_step.tooltip": "The default scroll step to use on zooming in.", + "config.ok_zoomer.zoom_values.scroll_step_limit": "Scroll Step Limit", + "config.ok_zoomer.zoom_values.scroll_step_limit.tooltip": "The maximum amount of scroll steps that the zoom may reach.", "config.ok_zoomer.zoom_values.cinematic_multiplier": "Cinematic Multiplier", - "config.ok_zoomer.zoom_values.cinematic_multiplier.tooltip": "The multiplier used for the multiplied cinematic camera.", + "config.ok_zoomer.zoom_values.cinematic_multiplier.tooltip": "The multiplier used by the multiplied cinematic camera.", + "config.ok_zoomer.legacy_scroll_values": "Legacy Scroll Values", + "config.ok_zoomer.legacy_scroll_values.zoom_divisor": "Zoom Divisor", + "config.ok_zoomer.legacy_scroll_values.zoom_divisor.tooltip": "The divisor used to apply zoom to the FOV. A higher value means more zoom.", + "config.ok_zoomer.legacy_scroll_values.minimum_zoom_divisor": "Minimum Zoom Divisor", + "config.ok_zoomer.legacy_scroll_values.minimum_zoom_divisor.tooltip": "The minimum zoom divisor that you can scroll down.", + "config.ok_zoomer.legacy_scroll_values.maximum_zoom_divisor": "Maximum Zoom Divisor", + "config.ok_zoomer.legacy_scroll_values.maximum_zoom_divisor.tooltip": "The maximum zoom divisor that you can scroll up.", + "config.ok_zoomer.legacy_scroll_values.lower_scroll_steps": "Lower Scroll Steps", + "config.ok_zoomer.legacy_scroll_values.lower_scroll_steps.tooltip": "The number of steps between the zoom divisor and the minimum zoom divisor. Used by zoom scrolling.", + "config.ok_zoomer.legacy_scroll_values.upper_scroll_steps": "Upper Scroll Steps", + "config.ok_zoomer.legacy_scroll_values.upper_scroll_steps.tooltip": "The number of steps between the zoom divisor and the maximum zoom divisor. Used by zoom scrolling.", "config.ok_zoomer.transition_values": "Transition Values", "config.ok_zoomer.transition_values.smooth_transition_factor": "Smooth Transition Factor", "config.ok_zoomer.transition_values.smooth_transition_factor.tooltip": "The factor used for smooth zoom transitions. A lower value means a smoother transition, a higher value means a faster one.", - "config.ok_zoomer.transition_values.minimum_linear_step": "Minimum Linear Step", - "config.ok_zoomer.transition_values.minimum_linear_step.tooltip": "The minimum value which the linear zoom transition step can reach.", - "config.ok_zoomer.transition_values.maximum_linear_step": "Maximum Linear Step", - "config.ok_zoomer.transition_values.maximum_linear_step.tooltip": "The maximum value which the linear zoom transition step can reach.", + "config.ok_zoomer.transition_values.linear_step": "Linear Step", + "config.ok_zoomer.transition_values.linear_step.tooltip": "The value which the linear zoom transition step can reach.", "config.ok_zoomer.tweaks": "Tweaks", "config.ok_zoomer.tweaks.unbind_conflicting_key": "Unbind Conflicting Key", "config.ok_zoomer.tweaks.unbind_conflicting_key.tooltip": "If pressed, the \"Save Toolbar Activator\" keybind will be unbound if there's a conflict with the zoom key.", @@ -77,11 +89,20 @@ "config.ok_zoomer.tweaks.reset_zoom_with_mouse": "Reset Zoom with Mouse", "config.ok_zoomer.tweaks.reset_zoom_with_mouse.tooltip": "Allows for resetting the zoom with the middle mouse button.", "config.ok_zoomer.tweaks.smart_occlusion": "Smart Occlusion", - "config.ok_zoomer.tweaks.smart_occlusion.tooltip": "Improves performance by making the game render less of the world while zoomed in. This feature requires the Sodium mod in order to work.", + "config.ok_zoomer.tweaks.smart_occlusion.tooltip": "Improves performance by making the game render less of the world while zoomed in. This feature depends on the Sodium mod in order to work.", + "config.ok_zoomer.tweaks.see_distant_entities": "See Distant Entities", + "config.ok_zoomer.tweaks.see_distant_entities.off": "Off", + "config.ok_zoomer.tweaks.see_distant_entities.off.tooltip": "Keeps the entity distance intact while zooming in. Creatures and certain blocks may not be visible from afar.", + "config.ok_zoomer.tweaks.see_distant_entities.safe": "Safe", + "config.ok_zoomer.tweaks.see_distant_entities.safe.tooltip": "Expands the entity distance while zooming in, allowing creatures and certain blocks to be seen from afar. This will only be enabled if the Sodium mod is installed.", + "config.ok_zoomer.tweaks.see_distant_entities.on": "On", + "config.ok_zoomer.tweaks.see_distant_entities.on.tooltip": "Expands the entity distance while zooming in, allowing creatures and certain blocks to be seen from afar. Without having Sodium installed, this may have a big performance impact during zoom.", "config.ok_zoomer.tweaks.forget_zoom_divisor": "Forget Zoom Divisor", "config.ok_zoomer.tweaks.forget_zoom_divisor.tooltip": "If enabled, the current zoom divisor is forgotten once zooming is finished.", "config.ok_zoomer.tweaks.use_spyglass_sounds": "Use Spyglass Sounds", "config.ok_zoomer.tweaks.use_spyglass_sounds.tooltip": "If enabled, the zoom will use spyglass sounds on zooming in and out.", + "config.ok_zoomer.tweaks.debug_scrolling": "Debug Scrolling", + "config.ok_zoomer.tweaks.debug_scrolling.tooltip": "Displays debug information for exponential zoom scrolling. Currently it may help with configuring the zoom scrolling.", "config.ok_zoomer.tweaks.print_owo_on_start": "Print owo on Start", "config.ok_zoomer.tweaks.print_owo_on_start.tooltip": "Prints a random owo in the console when the game starts.", "config.ok_zoomer.presets": "Presets", diff --git a/common/src/main/resources/assets/ok_zoomer/lang/pt_br.json b/common/src/main/resources/assets/ok_zoomer/lang/pt_br.json index 8c93f820..6a84d27d 100644 --- a/common/src/main/resources/assets/ok_zoomer/lang/pt_br.json +++ b/common/src/main/resources/assets/ok_zoomer/lang/pt_br.json @@ -29,6 +29,11 @@ "config.ok_zoomer.features.zoom_mode.persistent.tooltip": "O zoom sempre será ligado, com a tecla do zoom sendo usado para a rolagem do zoom.", "config.ok_zoomer.features.zoom_scrolling": "Rolagem de zoom", "config.ok_zoomer.features.zoom_scrolling.tooltip": "Permite aumentar ou diminuir o zoom com a rolagem do mouse.", + "config.ok_zoomer.features.scrolling_mode": "Modo de rolagem", + "config.ok_zoomer.features.scrolling_mode.exponential": "Exponencial", + "config.ok_zoomer.features.scrolling_mode.exponential.tooltip": "O zoom irá rolar de forma exponencial, dando consistência para os passos de zoom. Atualmente isso poderá ser mais difícil de configurar.", + "config.ok_zoomer.features.scrolling_mode.legacy": "Legado", + "config.ok_zoomer.features.scrolling_mode.legacy.tooltip": "O zoom irá rolar de forma arbitrária. Atualmente isso poderá ser mais fácil de configurar, porém a rolagem pode ser mais difícil em níveis de zoom maiores.", "config.ok_zoomer.features.persistent_interface": "Interface persistente", "config.ok_zoomer.features.persistent_interface.tooltip": "Retém a interface durante o zoom.", "config.ok_zoomer.features.extra_key_binds": "Atalhos extra", @@ -50,25 +55,32 @@ "config.ok_zoomer.features.spyglass_mode.both": "Ambas", "config.ok_zoomer.features.spyglass_mode.both.tooltip": "O zoom irá atuar como um substituto completo do zoom da luneta, dependendo de uma pra funcionar assim como substituindo o seu zoom.", "config.ok_zoomer.zoom_values": "Valores do zoom", - "config.ok_zoomer.zoom_values.zoom_divisor": "Divisor de zoom", - "config.ok_zoomer.zoom_values.zoom_divisor.tooltip": "O divisor usado para aplicar zoom no campo de visão. Um valor maior significa mais zoom.", - "config.ok_zoomer.zoom_values.minimum_zoom_divisor": "Divisor de zoom mínimo", - "config.ok_zoomer.zoom_values.minimum_zoom_divisor.tooltip": "O valor mínimo que o divisor pode ser rolado.", - "config.ok_zoomer.zoom_values.maximum_zoom_divisor": "Divisor de zoom máximo", - "config.ok_zoomer.zoom_values.maximum_zoom_divisor.tooltip": "O valor máximo que o divisor pode ser rolado.", - "config.ok_zoomer.zoom_values.lower_scroll_steps": "Passos de rolagem inferior", - "config.ok_zoomer.zoom_values.lower_scroll_steps.tooltip": "O número de passos entre o divisor de zoom e o divisor de zoom mínimo.\nUsado pela rolagem de zoom.", - "config.ok_zoomer.zoom_values.upper_scroll_steps": "Passos de rolagem superior", - "config.ok_zoomer.zoom_values.upper_scroll_steps.tooltip": "O número de passos entre o divisor de zoom e o divisor de zoom máximo.\nUsado pela rolagem de zoom.", + "config.ok_zoomer.zoom_values.scroll_base": "Base da rolagem", + "config.ok_zoomer.zoom_values.scroll_base.tooltip": "Determina o número a ser usado na curva exponencial. Em caso de dúvida, mantenha esse valor no 2.", + "config.ok_zoomer.zoom_values.scroll_resolution": "Resolução da rolagem", + "config.ok_zoomer.zoom_values.scroll_resolution.tooltip": "Determina a resolução da rolagem de zoom. Isso irá efetivamente multiplicar a quantidade de passos de rolagem.", + "config.ok_zoomer.zoom_values.default_scroll_step": "Passo de rolagem padrão", + "config.ok_zoomer.zoom_values.default_scroll_step.tooltip": "O passo de rolagem padrão a ser usado ao iniciar o zoom.", + "config.ok_zoomer.zoom_values.scroll_step_limit": "Limite de passo de rolagem", + "config.ok_zoomer.zoom_values.scroll_step_limit.tooltip": "A quantidade máxima de passos de rolagem a qual o zoom pode alcançar.", "config.ok_zoomer.zoom_values.cinematic_multiplier": "Multiplicador cinemático", - "config.ok_zoomer.zoom_values.cinematic_multiplier.tooltip": "O multiplicador usado na câmera cinemática multiplicada.", + "config.ok_zoomer.zoom_values.cinematic_multiplier.tooltip": "O multiplicador usado pela câmera cinemática multiplicada.", + "config.ok_zoomer.legacy_scroll_values": "Valores de rolagem legado", + "config.ok_zoomer.legacy_scroll_values.zoom_divisor": "Divisor de zoom", + "config.ok_zoomer.legacy_scroll_values.zoom_divisor.tooltip": "O divisor usado para aplicar zoom no campo de visão. Um valor maior significa mais zoom.", + "config.ok_zoomer.legacy_scroll_values.minimum_zoom_divisor": "Divisor de zoom mínimo", + "config.ok_zoomer.legacy_scroll_values.minimum_zoom_divisor.tooltip": "O valor mínimo que o divisor pode ser rolado.", + "config.ok_zoomer.legacy_scroll_values.maximum_zoom_divisor": "Divisor de zoom máximo", + "config.ok_zoomer.legacy_scroll_values.maximum_zoom_divisor.tooltip": "O valor máximo que o divisor pode ser rolado.", + "config.ok_zoomer.legacy_scroll_values.lower_scroll_steps": "Passos de rolagem inferior", + "config.ok_zoomer.legacy_scroll_values.lower_scroll_steps.tooltip": "O número de passos entre o divisor de zoom e o divisor de zoom mínimo.\nUsado pela rolagem de zoom.", + "config.ok_zoomer.legacy_scroll_values.upper_scroll_steps": "Passos de rolagem superior", + "config.ok_zoomer.legacy_scroll_values.upper_scroll_steps.tooltip": "O número de passos entre o divisor de zoom e o divisor de zoom máximo.\nUsado pela rolagem de zoom.", "config.ok_zoomer.transition_values": "Valores da transição", "config.ok_zoomer.transition_values.smooth_transition_factor": "Fator da transição suave", "config.ok_zoomer.transition_values.smooth_transition_factor.tooltip": "O fator usado nas transições de zoom suaves. Um valor menor significa uma transição mais suave, um valor maior significa uma mais rápida.", - "config.ok_zoomer.transition_values.minimum_linear_step": "Passo linear mínimo", - "config.ok_zoomer.transition_values.minimum_linear_step.tooltip": "O valor mínimo que o passo da transição linear pode alcançar.", - "config.ok_zoomer.transition_values.maximum_linear_step": "Passo linear máximo", - "config.ok_zoomer.transition_values.maximum_linear_step.tooltip": "O valor máximo que o passo da transição linear pode alcançar.", + "config.ok_zoomer.transition_values.linear_step": "Passo linear", + "config.ok_zoomer.transition_values.linear_step.tooltip": "O valor a qual o passo da transição linear pode alcançar.", "config.ok_zoomer.tweaks": "Ajustes", "config.ok_zoomer.tweaks.unbind_conflicting_key": "Corrigir atalho conflitante", "config.ok_zoomer.tweaks.unbind_conflicting_key.tooltip": "Se pressionado, o atalho \"Salvar barra rápida\" será anulada caso tenha conflito com o atalho de zoom.", @@ -77,11 +89,20 @@ "config.ok_zoomer.tweaks.reset_zoom_with_mouse": "Reiniciar zoom com mouse", "config.ok_zoomer.tweaks.reset_zoom_with_mouse.tooltip": "Permite reiniciar o zoom com o botão do meio do mouse.", "config.ok_zoomer.tweaks.smart_occlusion": "Oclusão inteligente", - "config.ok_zoomer.tweaks.smart_occlusion.tooltip": "Melhora o desempenho ao fazer o jogo renderizar menos do mundo durante o zoom. Esta função requer o mod Sodium para poder funcionar.", + "config.ok_zoomer.tweaks.smart_occlusion.tooltip": "Melhora o desempenho ao fazer o jogo renderizar menos do mundo durante o zoom. Esta função depende do mod Sodium para poder funcionar.", + "config.ok_zoomer.tweaks.see_distant_entities": "Ver entidades distantes", + "config.ok_zoomer.tweaks.see_distant_entities.off": "Não", + "config.ok_zoomer.tweaks.see_distant_entities.off.tooltip": "Mantém a distância das entidades intacta durante o zoom. Criaturas e cretos blocos poderão não ser vistos de longe.", + "config.ok_zoomer.tweaks.see_distant_entities.safe": "Seguro", + "config.ok_zoomer.tweaks.see_distant_entities.safe.tooltip": "Expande a distância das entidades durante o zoom, permitindo com que criaturas e certos blocos sejam vistos de longe. Isso somente será ativado se o mod Sodium estiver instalado.", + "config.ok_zoomer.tweaks.see_distant_entities.on": "Sim", + "config.ok_zoomer.tweaks.see_distant_entities.on.tooltip": "Expande a distância das entidades durante o zoom, permitindo com que criaturas e certos blocos sejam vistos de longe. Sem o Sodium estar instalado, isto poderá ter um grande impacto de desempenho durante o zoom.", "config.ok_zoomer.tweaks.forget_zoom_divisor": "Esquecer divisor de zoom", "config.ok_zoomer.tweaks.forget_zoom_divisor.tooltip": "Se ativado, o divisor de zoom atual será esquecido quando o zoom terminar.", "config.ok_zoomer.tweaks.use_spyglass_sounds": "Usar sons da luneta", "config.ok_zoomer.tweaks.use_spyglass_sounds.tooltip": "Se ativado, o zoom irá usar os sons da luneta ao alternar o zoom.", + "config.ok_zoomer.tweaks.debug_scrolling": "Depurar rolagem", + "config.ok_zoomer.tweaks.debug_scrolling.tooltip": "Mostra informações de depuração da rolagem de zoom exponencial. Atualmente elas poderão ajudar com a configuração da rolagem de zoom.", "config.ok_zoomer.tweaks.print_owo_on_start": "Imprimir owo ao iniciar", "config.ok_zoomer.tweaks.print_owo_on_start.tooltip": "Imprime um owo aleatório no console quando o jogo inicia.", "config.ok_zoomer.presets": "Predefinições", diff --git a/common/src/main/resources/assets/ok_zoomer/lang/zh_cn.json b/common/src/main/resources/assets/ok_zoomer/lang/zh_cn.json index abf09f0a..75555560 100644 --- a/common/src/main/resources/assets/ok_zoomer/lang/zh_cn.json +++ b/common/src/main/resources/assets/ok_zoomer/lang/zh_cn.json @@ -45,24 +45,20 @@ "config.ok_zoomer.features.spyglass_mode.both": "两者", "config.ok_zoomer.features.spyglass_mode.both.tooltip": "缩放将完全替换望远镜缩放,需要望远镜才能工作并替换其缩放。", "config.ok_zoomer.zoom_values": "缩放值", - "config.ok_zoomer.zoom_values.zoom_divisor": "缩放倍数", - "config.ok_zoomer.zoom_values.minimum_zoom_divisor": "最小缩放倍数", - "config.ok_zoomer.zoom_values.minimum_zoom_divisor.tooltip": "你可以向下滚动的最小缩放倍数。", - "config.ok_zoomer.zoom_values.maximum_zoom_divisor": "最大缩放倍数", - "config.ok_zoomer.zoom_values.maximum_zoom_divisor.tooltip": "你可以向上滚动的最大缩放倍数。", - "config.ok_zoomer.zoom_values.lower_scroll_steps": "向下滚动步数", - "config.ok_zoomer.zoom_values.lower_scroll_steps.tooltip": "缩放倍数和最小缩放倍数之间的步数。用于缩放滚动。", - "config.ok_zoomer.zoom_values.upper_scroll_steps": "向上滚动步数", - "config.ok_zoomer.zoom_values.upper_scroll_steps.tooltip": "缩放倍数和最大缩放倍数之间的步数。用于缩放滚动。", "config.ok_zoomer.zoom_values.cinematic_multiplier": "电影镜头倍数", "config.ok_zoomer.zoom_values.cinematic_multiplier.tooltip": "用于电影镜头的倍数。", + "config.ok_zoomer.legacy_scroll_values.zoom_divisor": "缩放倍数", + "config.ok_zoomer.legacy_scroll_values.minimum_zoom_divisor": "最小缩放倍数", + "config.ok_zoomer.legacy_scroll_values.minimum_zoom_divisor.tooltip": "你可以向下滚动的最小缩放倍数。", + "config.ok_zoomer.legacy_scroll_values.maximum_zoom_divisor": "最大缩放倍数", + "config.ok_zoomer.legacy_scroll_values.maximum_zoom_divisor.tooltip": "你可以向上滚动的最大缩放倍数。", + "config.ok_zoomer.legacy_scroll_values.lower_scroll_steps": "向下滚动步数", + "config.ok_zoomer.legacy_scroll_values.lower_scroll_steps.tooltip": "缩放倍数和最小缩放倍数之间的步数。用于缩放滚动。", + "config.ok_zoomer.legacy_scroll_values.upper_scroll_steps": "向上滚动步数", + "config.ok_zoomer.legacy_scroll_values.upper_scroll_steps.tooltip": "缩放倍数和最大缩放倍数之间的步数。用于缩放滚动。", "config.ok_zoomer.transition_values": "过渡值", "config.ok_zoomer.transition_values.smooth_transition_factor": "平滑过渡因子", "config.ok_zoomer.transition_values.smooth_transition_factor.tooltip": "用于平滑缩放过渡的因子。数值越低表示过渡越平滑,数值越高表示过渡越快。", - "config.ok_zoomer.transition_values.minimum_linear_step": "最小线性步长", - "config.ok_zoomer.transition_values.minimum_linear_step.tooltip": "线性缩放过渡步长可以达到的最小值。", - "config.ok_zoomer.transition_values.maximum_linear_step": "最大线性步长", - "config.ok_zoomer.transition_values.maximum_linear_step.tooltip": "线性缩放过渡步长可以达到的最大值。", "config.ok_zoomer.tweaks": "调整", "config.ok_zoomer.tweaks.unbind_conflicting_key": "解除冲突键位", "config.ok_zoomer.tweaks.unbind_conflicting_key.tooltip": "如果按下,当与缩放键冲突时,将解除“保存工具栏激活器”键位绑定。", diff --git a/common/src/main/resources/assets/ok_zoomer/lang/zh_tw.json b/common/src/main/resources/assets/ok_zoomer/lang/zh_tw.json index 17b09692..74266efe 100644 --- a/common/src/main/resources/assets/ok_zoomer/lang/zh_tw.json +++ b/common/src/main/resources/assets/ok_zoomer/lang/zh_tw.json @@ -45,24 +45,20 @@ "config.ok_zoomer.features.spyglass_mode.both": "兩者皆是", "config.ok_zoomer.features.spyglass_mode.both.tooltip": "縮放將作為望遠鏡縮放的完全替代品,需要一個才能工作,並且也取代其縮放。", "config.ok_zoomer.zoom_values": "縮放值", - "config.ok_zoomer.zoom_values.zoom_divisor": "縮放除數", - "config.ok_zoomer.zoom_values.minimum_zoom_divisor": "最小縮放除數", - "config.ok_zoomer.zoom_values.minimum_zoom_divisor.tooltip": "您可以向下捲動的最小縮放除數。", - "config.ok_zoomer.zoom_values.maximum_zoom_divisor": "最大縮放除數", - "config.ok_zoomer.zoom_values.maximum_zoom_divisor.tooltip": "您可以向上捲動的最大縮放除數。", - "config.ok_zoomer.zoom_values.lower_scroll_steps": "下捲動步數", - "config.ok_zoomer.zoom_values.lower_scroll_steps.tooltip": "縮放除數和最小縮放除數之間的步數。由縮放捲動使用。", - "config.ok_zoomer.zoom_values.upper_scroll_steps": "上捲動步數", - "config.ok_zoomer.zoom_values.upper_scroll_steps.tooltip": "縮放除數和最大縮放除數之間的步數。由縮放捲動使用。", "config.ok_zoomer.zoom_values.cinematic_multiplier": "視角平滑移動倍率", "config.ok_zoomer.zoom_values.cinematic_multiplier.tooltip": "用於倍率視角平滑移動的倍率。", + "config.ok_zoomer.legacy_scroll_values.zoom_divisor": "縮放除數", + "config.ok_zoomer.legacy_scroll_values.minimum_zoom_divisor": "最小縮放除數", + "config.ok_zoomer.legacy_scroll_values.minimum_zoom_divisor.tooltip": "您可以向下捲動的最小縮放除數。", + "config.ok_zoomer.legacy_scroll_values.maximum_zoom_divisor": "最大縮放除數", + "config.ok_zoomer.legacy_scroll_values.maximum_zoom_divisor.tooltip": "您可以向上捲動的最大縮放除數。", + "config.ok_zoomer.legacy_scroll_values.lower_scroll_steps": "下捲動步數", + "config.ok_zoomer.legacy_scroll_values.lower_scroll_steps.tooltip": "縮放除數和最小縮放除數之間的步數。由縮放捲動使用。", + "config.ok_zoomer.legacy_scroll_values.upper_scroll_steps": "上捲動步數", + "config.ok_zoomer.legacy_scroll_values.upper_scroll_steps.tooltip": "縮放除數和最大縮放除數之間的步數。由縮放捲動使用。", "config.ok_zoomer.transition_values": "過渡值", "config.ok_zoomer.transition_values.smooth_transition_factor": "平滑過渡因子", "config.ok_zoomer.transition_values.smooth_transition_factor.tooltip": "用於平滑縮放過渡的因子。值越低意味著過渡越平滑,值越高意味著過渡越快。", - "config.ok_zoomer.transition_values.minimum_linear_step": "最小線性步數", - "config.ok_zoomer.transition_values.minimum_linear_step.tooltip": "線性縮放過渡步數可以達到的最小值。", - "config.ok_zoomer.transition_values.maximum_linear_step": "最大線性步數", - "config.ok_zoomer.transition_values.maximum_linear_step.tooltip": "線性縮放過渡步數可以達到的最大值。", "config.ok_zoomer.tweaks": "微調", "config.ok_zoomer.tweaks.unbind_conflicting_key": "解除衝突按鍵綁定", "config.ok_zoomer.tweaks.unbind_conflicting_key.tooltip": "如果按下,「儲存工具列啟動器」按鍵綁定將在與縮放鍵發生衝突時解除綁定。", diff --git a/common/src/main/resources/ok_zoomer.mixins.json b/common/src/main/resources/ok_zoomer.mixins.json index e12da6a9..68ea8704 100644 --- a/common/src/main/resources/ok_zoomer.mixins.json +++ b/common/src/main/resources/ok_zoomer.mixins.json @@ -1,18 +1,21 @@ { - "required": true, - "minVersion": "0.8", - "package": "io.github.ennuil.ok_zoomer.mixin", - "compatibilityLevel": "JAVA_21", - "client": [ - "common.AbstractClientPlayerMixin", - "common.EditBoxAccessor", - "common.EditBoxMixin", - "common.GameRendererMixin", - "common.GuiMixin", - "common.MouseHandlerMixin", - "common.RenderStateShardMixin" - ], - "injectors": { - "defaultRequire": 1 + "required": true, + "minVersion": "0.8", + "package": "io.github.ennuil.ok_zoomer.mixin.common", + "compatibilityLevel": "JAVA_21", + "client": [ + "AbstractClientPlayerMixin", + "BlockEntityRendererMixin", + "EditBoxAccessor", + "EditBoxMixin", + "GameRendererMixin", + "GuiMixin", + "IntegratedServerMixin", + "LevelRendererMixin", + "MouseHandlerMixin", + "RenderStateShardMixin" + ], + "injectors": { + "defaultRequire": 1 } } diff --git a/fabric/src/main/java/io/github/ennuil/ok_zoomer/wrench_wrapper/fabric/FabricWrapper.java b/fabric/src/main/java/io/github/ennuil/ok_zoomer/wrench_wrapper/fabric/FabricWrapper.java index f127b612..c0fb01da 100644 --- a/fabric/src/main/java/io/github/ennuil/ok_zoomer/wrench_wrapper/fabric/FabricWrapper.java +++ b/fabric/src/main/java/io/github/ennuil/ok_zoomer/wrench_wrapper/fabric/FabricWrapper.java @@ -13,4 +13,8 @@ public class FabricWrapper { public static C create(String family, String id, Class configCreatorClass) { return ConfigFactory.create(CONFIG_ENVIRONMENT, family, id, configCreatorClass); } + + public static ConfigEnvironment getConfigEnvironment() { + return FabricWrapper.CONFIG_ENVIRONMENT; + } } diff --git a/fabric/src/main/java/io/github/ennuil/ok_zoomer/wrench_wrapper/quilt/QuiltWrapper.java b/fabric/src/main/java/io/github/ennuil/ok_zoomer/wrench_wrapper/quilt/QuiltWrapper.java index 804551db..c5a767d9 100644 --- a/fabric/src/main/java/io/github/ennuil/ok_zoomer/wrench_wrapper/quilt/QuiltWrapper.java +++ b/fabric/src/main/java/io/github/ennuil/ok_zoomer/wrench_wrapper/quilt/QuiltWrapper.java @@ -2,6 +2,7 @@ import io.github.ennuil.ok_zoomer.wrench_wrapper.WrenchWrapper; import org.quiltmc.config.api.ReflectiveConfig; +import org.quiltmc.config.implementor_api.ConfigEnvironment; import java.lang.reflect.InvocationTargetException; @@ -16,4 +17,15 @@ public static C create(String family, String id, Cl return null; } } + + public static ConfigEnvironment getConfigEnvironment() { + var clazz = WrenchWrapper.getClass("org.quiltmc.loader.impl.config.QuiltConfigImpl"); + if (clazz == null) return null; + + try { + return (ConfigEnvironment) clazz.getMethod("getConfigEnvironment").invoke(null); + } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { + return null; + } + } } diff --git a/fabric/src/main/resources/assets/ok_zoomer/icon.png b/fabric/src/main/resources/assets/ok_zoomer/icon.png index 28f14139..7a5239be 100644 Binary files a/fabric/src/main/resources/assets/ok_zoomer/icon.png and b/fabric/src/main/resources/assets/ok_zoomer/icon.png differ diff --git a/norge/src/main/java/io/github/ennuil/ok_zoomer/wrench_wrapper/norge/NorgeWrapper.java b/norge/src/main/java/io/github/ennuil/ok_zoomer/wrench_wrapper/norge/NorgeWrapper.java index cf637707..53277fd7 100644 --- a/norge/src/main/java/io/github/ennuil/ok_zoomer/wrench_wrapper/norge/NorgeWrapper.java +++ b/norge/src/main/java/io/github/ennuil/ok_zoomer/wrench_wrapper/norge/NorgeWrapper.java @@ -13,4 +13,8 @@ public class NorgeWrapper { public static C create(String family, String id, Class configCreatorClass) { return ConfigFactory.create(CONFIG_ENVIRONMENT, family, id, configCreatorClass); } + + public static ConfigEnvironment getConfigEnvironment() { + return NorgeWrapper.CONFIG_ENVIRONMENT; + } }