From 511498e0e08c200f21d6e8fef5a26559ab058de3 Mon Sep 17 00:00:00 2001 From: Blexyel Date: Tue, 13 May 2025 22:22:57 +0200 Subject: [PATCH 1/2] feat: add Forge section Signed-off-by: Blexyel --- forge.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/forge.md b/forge.md index 5eeacc1..3a0dc8c 100644 --- a/forge.md +++ b/forge.md @@ -5,3 +5,12 @@ **However, there is nothing stopping you from doing it yourself by forking the project,** **but please do not call it an official port. Make it clear it is unsupported by us.** + + +## UNSUPPORTED + +**It is possible to run FoxClient on Forge/NeoForge\* with [Sinytra Connector](https://modrinth.com/mod/connector) and [Forgified Fabric API](https://modrinth.com/mod/forgified-fabric-api)** + +**For ModMenu support, you can also drop the corresponding ModMenu jar into your mods folder** + +\* *This is not officially supported by us, so if anything breaks, please do not open an issue here* \ No newline at end of file From 0ec2e0f32e53ca3e8da57f9cb2ecf24ff5aac10f Mon Sep 17 00:00:00 2001 From: Blexyel Date: Tue, 20 May 2025 06:34:55 +0200 Subject: [PATCH 2/2] feat: future-proof zoom, fix: smooth zoom Signed-off-by: Blexyel --- .../foxclient/mixin/GameRendererMixin.java | 28 ++++++++----- .../foxclient/mixin/MouseMixin.java | 15 ++++--- .../foxes4life/foxclient/util/ZoomUtils.java | 39 ++++++++++++------- 3 files changed, 52 insertions(+), 30 deletions(-) diff --git a/src/main/java/net/foxes4life/foxclient/mixin/GameRendererMixin.java b/src/main/java/net/foxes4life/foxclient/mixin/GameRendererMixin.java index 247f426..0145ce7 100644 --- a/src/main/java/net/foxes4life/foxclient/mixin/GameRendererMixin.java +++ b/src/main/java/net/foxes4life/foxclient/mixin/GameRendererMixin.java @@ -8,19 +8,27 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + @Mixin(GameRenderer.class) public class GameRendererMixin { - @Inject(at = @At("TAIL"), method = "getFov", cancellable = true) - private void getFov(Camera camera, float tickDelta, boolean changingFov, CallbackInfoReturnable cir) { + @Inject(method = "getFov", at = @At("TAIL"), cancellable = true) + private void onGetFov(Camera camera, float tickDelta, boolean changingFov, CallbackInfoReturnable cir) { + double baseFov = cir.getReturnValue(); + + // Handle key state and smooth camera toggle + ZoomUtils.smoothCam(); + + // Set the desired target zoom level based on key state if (ZoomUtils.zoomin()) { - ZoomUtils.currentZoomLevel = cir.getReturnValue() * ZoomUtils.zoomModifier; - ZoomUtils.calculateZoom(); - cir.setReturnValue(ZoomUtils.actualZoomLevel); + ZoomUtils.currentZoomLevel = baseFov * ZoomUtils.zoomedFov; } else { - ZoomUtils.zoomModifier = 0.2F; - ZoomUtils.currentZoomLevel = cir.getReturnValue(); - ZoomUtils.actualZoomLevel = cir.getReturnValue(); + ZoomUtils.currentZoomLevel = baseFov; } - ZoomUtils.smoothCam(); + + // Smoothly interpolate toward target + ZoomUtils.calculateZoom(); + + // Override FOV with interpolated zoom value + cir.setReturnValue(ZoomUtils.actualZoomLevel); } -} +} \ No newline at end of file diff --git a/src/main/java/net/foxes4life/foxclient/mixin/MouseMixin.java b/src/main/java/net/foxes4life/foxclient/mixin/MouseMixin.java index 6f4a57f..11c225b 100644 --- a/src/main/java/net/foxes4life/foxclient/mixin/MouseMixin.java +++ b/src/main/java/net/foxes4life/foxclient/mixin/MouseMixin.java @@ -9,15 +9,20 @@ @Mixin(Mouse.class) public class MouseMixin { - @Inject(at = @At("HEAD"), method = "onMouseScroll", cancellable = true) + @Inject(method = "onMouseScroll", at = @At("HEAD"), cancellable = true) private void onMouseScroll(long window, double horizontal, double vertical, CallbackInfo ci) { if (ZoomUtils.zoomin()) { - ci.cancel(); + ci.cancel(); // Prevent default scroll behavior while zooming + + // Adjust zoomed FOV modifier within safe bounds if (vertical > 0) { - if (!(ZoomUtils.zoomModifier < 0.1)) ZoomUtils.zoomModifier -= 0.05; + ZoomUtils.zoomedFov = Math.max(0.05F, ZoomUtils.zoomedFov - 0.05F); } else { - if (!(ZoomUtils.zoomModifier > 1)) ZoomUtils.zoomModifier += 0.05; + ZoomUtils.zoomedFov = Math.min(1.0F, ZoomUtils.zoomedFov + 0.05F); } + + // Update target zoom level to reflect scroll + ZoomUtils.currentZoomLevel = ZoomUtils.actualZoomLevel * ZoomUtils.zoomedFov; } } -} +} \ No newline at end of file diff --git a/src/main/java/net/foxes4life/foxclient/util/ZoomUtils.java b/src/main/java/net/foxes4life/foxclient/util/ZoomUtils.java index 6ab1c7b..34a4506 100644 --- a/src/main/java/net/foxes4life/foxclient/util/ZoomUtils.java +++ b/src/main/java/net/foxes4life/foxclient/util/ZoomUtils.java @@ -10,14 +10,17 @@ public class ZoomUtils { private static final KeyBinding zoomKey = new KeyBinding("key.foxclient.zoom", GLFW.GLFW_KEY_C, "category.foxclient.main"); - static boolean isZoomin = false; - public static float zoomModifier = 0.2F; - public static double currentZoomLevel = 0.2F; - public static double actualZoomLevel = 0.2F; + public static boolean isZoomin = false; + + public static float zoomedFovDefault = 0.2F; + public static float zoomedFov = 0.2F; // Zoomed-in FOV scale + public static float defaultFov = 1.0F; // Normal FOV scale + + public static double currentZoomLevel = 1.0F; // The target zoom level + public static double actualZoomLevel = 1.0F; // The lerped FOV value public static void initZoom() { KeyBindingHelper.registerKeyBinding(zoomKey); - isZoomin = false; } public static boolean zoomin() { @@ -25,22 +28,28 @@ public static boolean zoomin() { } public static void smoothCam() { - //start holdin - if (zoomin() && !isZoomin) { - isZoomin = true; - MinecraftClient.getInstance().options.smoothCameraEnabled = true; - } + if (zoomin()) { + if (!isZoomin) { + isZoomin = true; + MinecraftClient.getInstance().options.smoothCameraEnabled = true; + } - //stop holdin - if (!zoomin() && isZoomin) { - isZoomin = false; - MinecraftClient.getInstance().options.smoothCameraEnabled = false; + currentZoomLevel = zoomedFov; + } else { + if (isZoomin) { + isZoomin = false; + MinecraftClient.getInstance().options.smoothCameraEnabled = false; + + zoomedFov = zoomedFovDefault; + } + currentZoomLevel = defaultFov; } } + public static void calculateZoom() { ZoomUtils.actualZoomLevel = Main.config.get(FoxClientSetting.SmoothZoom, Boolean.class) ? - MathHelper.lerp(0.05f, ZoomUtils.actualZoomLevel, ZoomUtils.currentZoomLevel) : + MathHelper.lerp(0.1f, (float) actualZoomLevel, (float) currentZoomLevel) : ZoomUtils.currentZoomLevel; } }