Fixed bug in zoom feature
All checks were successful
build / build (push) Successful in 54s

This commit is contained in:
2025-06-22 15:15:36 +02:00
parent 2d3ac6b0ed
commit 16fab96836
3 changed files with 10 additions and 3 deletions

View File

@@ -69,7 +69,10 @@ Code inspired by Inferis!
- Zoom step value
- Scroll to zoom further
# Current Update
# Next Update
## Client Side
- [x] Fixed bug with too high zoom step values
## Server Side
- [x] Telekinesis

View File

@@ -20,6 +20,8 @@ public class Zoom {
@Unique
private static boolean initialSmoothZoom;
@Unique
private static boolean initialRenderHand;
public static void register() {
ClientTickEvents.END_CLIENT_TICK.register(client -> {
@@ -30,7 +32,9 @@ public class Zoom {
MinecraftClient.getInstance().options.smoothCameraEnabled = true;
}
SHOULD_ZOOM = true;
client.gameRenderer.setRenderHand(false);
} else if (!ZOOM_BIND.isPressed() && SHOULD_ZOOM) {
client.gameRenderer.setRenderHand(true);
SHOULD_ZOOM = false;
ZOOM_STEP = 0;
if(getConfig().smoothCamera) {
@@ -55,7 +59,7 @@ public class Zoom {
// Clamp the zoom level so the FOV stays within [1, 110]
float zoomFov = getZoomFov();
if (zoomFov < 1) {
ZOOM_STEP = Math.round((1 - getConfig().initialZoom) / getConfig().zoomStep) + 1;
ZOOM_STEP = Math.round((1 - getConfig().initialZoom) / getConfig().zoomStep);
} else if (zoomFov > 110) {
ZOOM_STEP = Math.round((110 - getConfig().initialZoom) / getConfig().zoomStep);
}

View File

@@ -15,7 +15,7 @@ public class GameRendererMixin {
*/
@ModifyReturnValue(method = "getFov", at = @At("RETURN"))
private float modifyFovWithZoom(float fov, @Local(argsOnly = true) float tickDelta) {
return Zoom.isZooming() ? Zoom.getZoomFov() : fov;
return Zoom.isZooming() ? Math.clamp(Zoom.getZoomFov(), 1, 110) : fov;
}
}