diff --git a/src/main/java/io/github/ennuil/ok_zoomer/config/screen/ConfigTextUtils.java b/src/main/java/io/github/ennuil/ok_zoomer/config/screen/ConfigTextUtils.java index f7d0e26..640e88d 100644 --- a/src/main/java/io/github/ennuil/ok_zoomer/config/screen/ConfigTextUtils.java +++ b/src/main/java/io/github/ennuil/ok_zoomer/config/screen/ConfigTextUtils.java @@ -19,9 +19,9 @@ public ConfigTextUtils(Config config) { this.scheme = this.config.metadata(SerializedNameConvention.TYPE); } - public static Component getConfigTitle(ResourceLocation configId) { - return Component.translatable("config." + configId.getNamespace() + ".title"); - } + public static Component getConfigTitle(ResourceLocation configId) { + return Component.translatable("config." + configId.getNamespace() + ".title"); + } public Component getCategoryText(String category) { return Component.translatable("config." + this.config.family() + "." + this.scheme.coerce(category)); diff --git a/src/main/java/io/github/ennuil/ok_zoomer/zoom/modifiers/MultipliedCinematicCameraMouseModifier.java b/src/main/java/io/github/ennuil/ok_zoomer/zoom/modifiers/MultipliedCinematicCameraMouseModifier.java index f6e8eec..716c94e 100644 --- a/src/main/java/io/github/ennuil/ok_zoomer/zoom/modifiers/MultipliedCinematicCameraMouseModifier.java +++ b/src/main/java/io/github/ennuil/ok_zoomer/zoom/modifiers/MultipliedCinematicCameraMouseModifier.java @@ -5,50 +5,50 @@ // The implementation of the multiplied cinematic camera public class MultipliedCinematicCameraMouseModifier implements MouseModifier { - private final Minecraft minecraft; - private final SmoothDouble cursorXZoomSmoother = new SmoothDouble(); - private final SmoothDouble cursorYZoomSmoother = new SmoothDouble(); - private boolean active; - private boolean cinematicCameraEnabled; - private final double multiplier; - - public MultipliedCinematicCameraMouseModifier(double multiplier) { - this.multiplier = multiplier; - this.minecraft = Minecraft.getInstance(); - } - - @Override - public boolean getActive() { - return this.active; - } - - @Override - public double applyXModifier(double cursorDeltaX, double cursorSensitivity, double mouseUpdateTimeDelta, double targetDivisor, double transitionMultiplier) { - if (this.cinematicCameraEnabled) { - this.cursorXZoomSmoother.reset(); - return cursorDeltaX; - } - - return this.cursorXZoomSmoother.getNewDeltaValue(cursorDeltaX, mouseUpdateTimeDelta * this.multiplier * cursorSensitivity); - } - - @Override - public double applyYModifier(double cursorDeltaY, double cursorSensitivity, double mouseUpdateTimeDelta, double targetDivisor, double transitionMultiplier) { - if (this.cinematicCameraEnabled) { - this.cursorYZoomSmoother.reset(); - return cursorDeltaY; - } - - return this.cursorYZoomSmoother.getNewDeltaValue(cursorDeltaY, mouseUpdateTimeDelta * this.multiplier * cursorSensitivity); - } - - @Override - public void tick(boolean active) { - this.cinematicCameraEnabled = this.minecraft.options.smoothCamera; - if (!active && this.active) { - this.cursorXZoomSmoother.reset(); - this.cursorYZoomSmoother.reset(); - } - this.active = active; - } + private final Minecraft minecraft; + private final SmoothDouble cursorXZoomSmoother = new SmoothDouble(); + private final SmoothDouble cursorYZoomSmoother = new SmoothDouble(); + private boolean active; + private boolean cinematicCameraEnabled; + private final double multiplier; + + public MultipliedCinematicCameraMouseModifier(double multiplier) { + this.multiplier = multiplier; + this.minecraft = Minecraft.getInstance(); + } + + @Override + public boolean getActive() { + return this.active; + } + + @Override + public double applyXModifier(double cursorDeltaX, double cursorSensitivity, double mouseUpdateTimeDelta, double targetDivisor, double transitionMultiplier) { + if (this.cinematicCameraEnabled) { + this.cursorXZoomSmoother.reset(); + return cursorDeltaX; + } + + return this.cursorXZoomSmoother.getNewDeltaValue(cursorDeltaX, mouseUpdateTimeDelta * this.multiplier * cursorSensitivity); + } + + @Override + public double applyYModifier(double cursorDeltaY, double cursorSensitivity, double mouseUpdateTimeDelta, double targetDivisor, double transitionMultiplier) { + if (this.cinematicCameraEnabled) { + this.cursorYZoomSmoother.reset(); + return cursorDeltaY; + } + + return this.cursorYZoomSmoother.getNewDeltaValue(cursorDeltaY, mouseUpdateTimeDelta * this.multiplier * cursorSensitivity); + } + + @Override + public void tick(boolean active) { + this.cinematicCameraEnabled = this.minecraft.options.smoothCamera; + if (!active && this.active) { + this.cursorXZoomSmoother.reset(); + this.cursorYZoomSmoother.reset(); + } + this.active = active; + } } diff --git a/src/main/java/io/github/ennuil/ok_zoomer/zoom/modifiers/SpyglassMouseModifier.java b/src/main/java/io/github/ennuil/ok_zoomer/zoom/modifiers/SpyglassMouseModifier.java deleted file mode 100644 index 730af2f..0000000 --- a/src/main/java/io/github/ennuil/ok_zoomer/zoom/modifiers/SpyglassMouseModifier.java +++ /dev/null @@ -1,35 +0,0 @@ -package io.github.ennuil.ok_zoomer.zoom.modifiers; - -/** - * An implementation of the spyglass' reduction of the mouse sensitivity as a mouse modifier -*/ -public class SpyglassMouseModifier implements MouseModifier { - private boolean active; - - /** - * Initializes an instance of the spyglass mouse modifier. - */ - public SpyglassMouseModifier() { - this.active = false; - } - - @Override - public boolean getActive() { - return this.active; - } - - @Override - public double applyXModifier(double cursorDeltaX, double cursorSensitivity, double mouseUpdateTimeDelta, double targetDivisor, double transitionMultiplier) { - return cursorDeltaX / (this.active ? 8.0 : 1.0); - } - - @Override - public double applyYModifier(double cursorDeltaY, double cursorSensitivity, double mouseUpdateTimeDelta, double targetDivisor, double transitionMultiplier) { - return cursorDeltaY / (this.active ? 8.0 : 1.0); - } - - @Override - public void tick(boolean active) { - this.active = active; - } -} diff --git a/src/main/java/io/github/ennuil/ok_zoomer/zoom/overlays/SpyglassZoomOverlay.java b/src/main/java/io/github/ennuil/ok_zoomer/zoom/overlays/SpyglassZoomOverlay.java index 84e1372..fe4b464 100644 --- a/src/main/java/io/github/ennuil/ok_zoomer/zoom/overlays/SpyglassZoomOverlay.java +++ b/src/main/java/io/github/ennuil/ok_zoomer/zoom/overlays/SpyglassZoomOverlay.java @@ -11,33 +11,33 @@ // An implementation of the spyglass overlay as a zoom overlay public class SpyglassZoomOverlay implements ZoomOverlay { - private final ResourceLocation textureId; - //private Minecraft minecraft; - private float scale; - private boolean active; + private final ResourceLocation textureId; + //private Minecraft minecraft; + private float scale; + private boolean active; - public SpyglassZoomOverlay(ResourceLocation textureId) { - this.textureId = textureId; - this.scale = 0.5F; - this.active = false; + public SpyglassZoomOverlay(ResourceLocation textureId) { + this.textureId = textureId; + this.scale = 0.5F; + this.active = false; //this.minecraft = Minecraft.getInstance(); - } + } - @Override - public boolean getActive() { - return this.active; - } + @Override + public boolean getActive() { + return this.active; + } - @Override - public boolean cancelOverlayRendering() { - return true; - } + @Override + public boolean cancelOverlayRendering() { + return true; + } // TODO - Consider whenever a third-person view block tweak option is desirable - @Override - public void renderOverlay(GuiGraphics graphics, DeltaTracker deltaTracker, TransitionMode transitionMode) { - int guiWidth = graphics.guiWidth(); - int guiHeight = graphics.guiHeight(); + @Override + public void renderOverlay(GuiGraphics graphics, DeltaTracker deltaTracker, TransitionMode transitionMode) { + int guiWidth = graphics.guiWidth(); + int guiHeight = graphics.guiHeight(); float smallerLength = (float) Math.min(guiWidth, guiHeight); float scaledSmallerLength = Math.min((float) guiWidth / smallerLength, (float) guiHeight / smallerLength) * scale; int width = Mth.floor(smallerLength * scaledSmallerLength); @@ -53,19 +53,19 @@ public void renderOverlay(GuiGraphics graphics, DeltaTracker deltaTracker, Trans graphics.fill(RenderType.guiOverlay(), 0, 0, guiWidth, y, -90, CommonColors.BLACK); graphics.fill(RenderType.guiOverlay(), 0, y, x, borderY, -90, CommonColors.BLACK); graphics.fill(RenderType.guiOverlay(), borderX, y, guiWidth, borderY, -90, CommonColors.BLACK); - } + } - @Override - public void tick(boolean active, double divisor, TransitionMode transitionMode) { - this.active = active; - } + @Override + public void tick(boolean active, double divisor, TransitionMode transitionMode) { + this.active = active; + } - @Override - public void tickBeforeRender(DeltaTracker deltaTracker) { + @Override + public void tickBeforeRender(DeltaTracker deltaTracker) { if (!this.active) { this.scale = 0.5F; } else { this.scale = Mth.lerp(0.5F * deltaTracker.getGameTimeDeltaTicks(), this.scale, 1.125F); } - } + } } diff --git a/src/main/java/io/github/ennuil/ok_zoomer/zoom/overlays/ZoomerZoomOverlay.java b/src/main/java/io/github/ennuil/ok_zoomer/zoom/overlays/ZoomerZoomOverlay.java index c25a0a8..419daa3 100644 --- a/src/main/java/io/github/ennuil/ok_zoomer/zoom/overlays/ZoomerZoomOverlay.java +++ b/src/main/java/io/github/ennuil/ok_zoomer/zoom/overlays/ZoomerZoomOverlay.java @@ -13,21 +13,21 @@ // Implements the zoom overlay public class ZoomerZoomOverlay implements ZoomOverlay { - private final ResourceLocation textureId; - private boolean active; + private final ResourceLocation textureId; + private boolean active; - public ZoomerZoomOverlay(ResourceLocation textureId) { - this.textureId = textureId; - this.active = false; - } + public ZoomerZoomOverlay(ResourceLocation textureId) { + this.textureId = textureId; + this.active = false; + } - @Override - public boolean getActive() { - return this.active; - } + @Override + public boolean getActive() { + return this.active; + } - @Override - public void renderOverlay(GuiGraphics graphics, DeltaTracker deltaTracker, TransitionMode transitionMode) { + @Override + public void renderOverlay(GuiGraphics graphics, DeltaTracker deltaTracker, TransitionMode transitionMode) { RenderSystem.disableDepthTest(); RenderSystem.depthMask(false); RenderSystem.enableBlend(); @@ -40,12 +40,12 @@ public void renderOverlay(GuiGraphics graphics, DeltaTracker deltaTracker, Trans RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.defaultBlendFunc(); RenderSystem.disableBlend(); - } + } - @Override - public void tick(boolean active, double divisor, TransitionMode transitionMode) { - if (active || !transitionMode.getActive()) { - this.active = active; - } - } + @Override + public void tick(boolean active, double divisor, TransitionMode transitionMode) { + if (active || !transitionMode.getActive()) { + this.active = active; + } + } } diff --git a/src/main/java/io/github/ennuil/ok_zoomer/zoom/transitions/LinearTransitionMode.java b/src/main/java/io/github/ennuil/ok_zoomer/zoom/transitions/LinearTransitionMode.java index 2fe81d5..074ecb1 100644 --- a/src/main/java/io/github/ennuil/ok_zoomer/zoom/transitions/LinearTransitionMode.java +++ b/src/main/java/io/github/ennuil/ok_zoomer/zoom/transitions/LinearTransitionMode.java @@ -4,35 +4,35 @@ // The implementation of the linear transition public class LinearTransitionMode implements TransitionMode { - private boolean active; - private final double minimumLinearStep; - private final double maximumLinearStep; - private float fovMultiplier; - private float internalMultiplier; - private float lastInternalMultiplier; + private boolean active; + private final double minimumLinearStep; + private final double maximumLinearStep; + private float fovMultiplier; + private float internalMultiplier; + private float lastInternalMultiplier; private float internalFade; private float lastInternalFade; - public LinearTransitionMode(double minimumLinearStep, double maximumLinearStep) { - this.active = false; - this.minimumLinearStep = minimumLinearStep; - this.maximumLinearStep = maximumLinearStep; - this.internalMultiplier = 1.0F; - this.lastInternalMultiplier = 1.0F; + public LinearTransitionMode(double minimumLinearStep, double maximumLinearStep) { + this.active = false; + this.minimumLinearStep = minimumLinearStep; + this.maximumLinearStep = maximumLinearStep; + this.internalMultiplier = 1.0F; + this.lastInternalMultiplier = 1.0F; this.internalFade = 0.0F; this.lastInternalFade = 0.0F; - } + } - @Override - public boolean getActive() { - return this.active; - } + @Override + public boolean getActive() { + return this.active; + } - @Override - public float applyZoom(float fov, float tickDelta) { - fovMultiplier = Mth.lerp(tickDelta, this.lastInternalMultiplier, this.internalMultiplier); - return fov * fovMultiplier; - } + @Override + public float applyZoom(float fov, float tickDelta) { + fovMultiplier = Mth.lerp(tickDelta, this.lastInternalMultiplier, this.internalMultiplier); + return fov * fovMultiplier; + } @Override public float getFade(float tickDelta) { @@ -40,24 +40,24 @@ public float getFade(float tickDelta) { } @Override - public void tick(boolean active, double divisor) { - double zoomMultiplier = 1.0 / divisor; + public void tick(boolean active, double divisor) { + double zoomMultiplier = 1.0 / divisor; double fadeMultiplier = active ? 1.0D : 0.0D; this.lastInternalMultiplier = this.internalMultiplier; this.lastInternalFade = this.internalFade; - double linearStep = Mth.clamp(zoomMultiplier, this.minimumLinearStep, this.maximumLinearStep); - this.internalMultiplier = Mth.approach(this.internalMultiplier, (float) zoomMultiplier, (float) linearStep); - this.internalFade = Mth.approach(this.internalFade, (float) fadeMultiplier, (float) linearStep); + double linearStep = Mth.clamp(zoomMultiplier, this.minimumLinearStep, this.maximumLinearStep); + this.internalMultiplier = Mth.approach(this.internalMultiplier, (float) zoomMultiplier, (float) linearStep); + this.internalFade = Mth.approach(this.internalFade, (float) fadeMultiplier, (float) linearStep); - if (active || fovMultiplier == this.internalMultiplier) { - this.active = active; - } - } + if (active || fovMultiplier == this.internalMultiplier) { + this.active = active; + } + } - @Override - public double getInternalMultiplier() { - return this.internalMultiplier; - } + @Override + public double getInternalMultiplier() { + return this.internalMultiplier; + } }