Skip to content

Commit

Permalink
zoom
Browse files Browse the repository at this point in the history
  • Loading branch information
ImToggle committed Feb 5, 2024
1 parent e7bec4e commit 700cbaf
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 20 deletions.
1 change: 1 addition & 0 deletions src/main/java/club/sk1er/patcher/Patcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ private void loadBlacklistedServers() {
}

private void fixSettings() {
if (PatcherConfig.customZoomSensitivity > 1.0F) PatcherConfig.customZoomSensitivity = 1.0F;
if (PatcherConfig.imagePreviewWidth > 1.0F) PatcherConfig.imagePreviewWidth = 0.5F;
if (PatcherConfig.previewScale > 1.0F) PatcherConfig.previewScale = 1.0F;
if (PatcherConfig.unfocusedFPSAmount < 15) PatcherConfig.unfocusedFPSAmount = 15;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,21 @@ public void transform(ClassNode classNode, String name) {

break;
}

case "func_78476_b":
case "renderHand": {
ListIterator<AbstractInsnNode> iterator = methodNode.instructions.iterator();
while (iterator.hasNext()) {
AbstractInsnNode next = iterator.next();

if (next instanceof MethodInsnNode && next.getOpcode() == Opcodes.INVOKESPECIAL) {
String methodName = mapMethodNameFromNode(next);
if (methodName.equals("getFOVModifier") || methodName.equals("func_78481_a")) {
methodNode.instructions.insert(next, new MethodInsnNode(Opcodes.INVOKESTATIC, getHookClass("EntityRendererHook"), "getHandFOVModifier", "(F)F", false));
}
}
}
}
}
}
}
Expand Down
8 changes: 0 additions & 8 deletions src/main/java/club/sk1er/patcher/commands/PatcherCommand.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package club.sk1er.patcher.commands;

import cc.polyfrost.oneconfig.libs.universal.UMinecraft;
import cc.polyfrost.oneconfig.utils.commands.annotations.*;
import club.sk1er.patcher.Patcher;
import club.sk1er.patcher.config.PatcherConfig;
import club.sk1er.patcher.hooks.MouseHelperHook;
import club.sk1er.patcher.util.chat.ChatUtilities;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
Expand Down Expand Up @@ -131,10 +129,4 @@ public void fps(@Description("amount") int amount) {
String message = amount == 0 ? "Custom framerate was reset." : "Custom framerate set to " + amount + ".";
ChatUtilities.sendNotification("Custom FPS Limiter", message);
}

@SubCommand(description = "Rescan devices for RawInput")
public void rescan() {
MouseHelperHook mouseHelper = ((MouseHelperHook) UMinecraft.getMinecraft().mouseHelper);
mouseHelper.getPolyfrost$rawInput().updateControllerEnvironment();
}
}
82 changes: 72 additions & 10 deletions src/main/java/club/sk1er/patcher/config/PatcherConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,71 @@ public class PatcherConfig extends Config {
)
public static boolean hideAuraOnInvisibleWither;

@Switch(
name = "Zoom Adjustment",
description = "Scroll when using OptiFine's zoom to adjust the zoom level.",
category = "Miscellaneous", subcategory = "OptiFine"
)
public static boolean scrollToZoom = true;

@Switch(
name = "Remove Smooth Camera While Zoomed",
description = "Remove the smooth camera effect when using zoom.",
category = "Miscellaneous", subcategory = "OptiFine"
)
public static boolean normalZoomSensitivity;

@Switch(
name = "Render Hand While Zoomed",
description = "Keep your hand on screen when you zoom in.",
category = "Miscellaneous", subcategory = "OptiFine"
)
public static boolean renderHandWhenZoomed;

@Slider(
name = "Zoom Sensitivity",
description = "Use a custom mouse sensitivity value when zoomed in.",
category = "Miscellaneous", subcategory = "OptiFine",
min = 0F, max = 1F
)
public static float customZoomSensitivity = 1.0F;

@Switch(
name = "Dynamic Zoom Sensitivity",
description = "Reduce your mouse sensitivity the more you zoom in.",
category = "Miscellaneous", subcategory = "OptiFine"
)
public static boolean dynamicZoomSensitivity;

@Switch(
name = "Smooth Zoom Animation",
description = "Add a smooth animation when you zoom in and out.",
category = "Miscellaneous", subcategory = "OptiFine"
)
public static boolean smoothZoomAnimation;

@Switch(
name = "Smooth Scroll-to-Zoom Animation",
description = "Add a smooth animation when you scroll in and out while zoomed.",
category = "Miscellaneous", subcategory = "OptiFine"
)
public static boolean smoothZoomAnimationWhenScrolling;

@Dropdown(
name = "Smooth Zoom Function",
description = "Change the smoothing function used in the smooth zooming animation.",
category = "Miscellaneous", subcategory = "OptiFine",
options = {"In Out Quad", "In Out Circular", "Out Quint"}
)
public static int smoothZoomAlgorithm = 0;

@Switch(
name = "Toggle to Zoom",
description = "Make OptiFine's zoom key a toggle instead of requiring you to hold it.",
category = "Miscellaneous", subcategory = "OptiFine"
)
public static boolean toggleToZoom;

@Switch(
name = "Simplify FPS Counter",
description = "Remove the extra FPS counter added by OptiFine.",
Expand Down Expand Up @@ -520,14 +585,6 @@ public class PatcherConfig extends Config {
)
public static boolean staticItems;

@Switch(
name = "Raw Input"
)
public static boolean rawInput = true;

@NonProfileSpecific
public static boolean osWarned = false;

@Button(
name = "Modify Every Sound",
text = "Modify",
Expand Down Expand Up @@ -1368,6 +1425,9 @@ public PatcherConfig() {
).forEach(property -> addDependency(property, "allowFovModifying"));

addDependency("logOptimizerLength", "logOptimizer");
addDependency("dynamicZoomSensitivity", "scrollToZoom");
addDependency("smoothZoomAnimation", "scrollToZoom");
addDependency("smoothZoomAlgorithm", "smoothZoomAnimation");

Arrays.asList(
"cullingInterval", "smartEntityCulling", "dontCullNametags",
Expand All @@ -1392,8 +1452,10 @@ public PatcherConfig() {

Supplier<Boolean> noOptiFine = () -> ClassTransformer.optifineVersion.equals("NONE");
Arrays.asList(
"normalFpsCounter", "useVanillaMetricsRenderer",
"smartFullbright", "smartEntityCulling"
"scrollToZoom", "normalZoomSensitivity", "customZoomSensitivity", "smoothZoomAnimation",
"smoothZoomAnimationWhenScrolling", "smoothZoomAlgorithm", "toggleToZoom", "normalFpsCounter",
"useVanillaMetricsRenderer", "renderHandWhenZoomed", "smartFullbright", "smartEntityCulling",
"dynamicZoomSensitivity"
).forEach(property -> hideIf(property, noOptiFine));

Supplier<Boolean> smoothFontDetected = () -> ClassTransformer.smoothFontDetected;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package club.sk1er.patcher.mixins.features;

import club.sk1er.patcher.config.PatcherConfig;
import club.sk1er.patcher.hooks.ZoomHook;
import net.minecraft.entity.player.InventoryPlayer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -11,7 +12,7 @@
public class InventoryPlayerTransformer_HotbarScrolling {
@Inject(method = "changeCurrentItem", at = @At("HEAD"), cancellable = true)
private void patcher$cancelScrolling(int direction, CallbackInfo ci) {
if (PatcherConfig.disableHotbarScrolling) {
if (PatcherConfig.disableHotbarScrolling || (PatcherConfig.scrollToZoom && ZoomHook.zoomed)) {
ci.cancel();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/mixins.patcher.json
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,10 @@
"features.network.packet.C01PacketChatMessageMixin_ExtendedChatLength",
"features.network.packet.S2EPacketCloseWindowMixin_NoCloseMyChat",
"features.optifine.ConfigMixin_SimplifyFpsCounter",
"features.optifine.EntityRendererMixin_ZoomTweaks",
"features.optifine.GuiOverlayDebugMixin_SimplifyFpsCounter",
"features.optifine.GuiOverlayDebugMixin_VanillaMetricsRenderer",
"features.optifine.LayerCapeMixin_NaturalCapes_OptifineCompat",
"features.rawinput.MouseHelperMixin",
"features.render.item.ItemRendererMixin_FireRendering",
"features.render.item.ItemRendererMixin_RemoveWaterOverlay",
"misc.GuiOverlayDebugMixin_ShowPatcherVersion",
Expand Down

0 comments on commit 700cbaf

Please sign in to comment.