Skip to content

Commit c0abdf2

Browse files
committed
merge: PR #125 add mouse wheel zoom to SmoothZoom
2 parents 347637d + bca7073 commit c0abdf2

File tree

6 files changed

+50
-14
lines changed

6 files changed

+50
-14
lines changed

src/main/java/top/fpsmaster/features/impl/optimizes/SmoothZoom.java

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package top.fpsmaster.features.impl.optimizes;
22

33
import org.lwjgl.input.Keyboard;
4+
import org.lwjgl.input.Mouse;
5+
import top.fpsmaster.FPSMaster;
46
import top.fpsmaster.event.Subscribe;
57
import top.fpsmaster.event.events.EventUpdate;
68
import top.fpsmaster.features.manager.Category;
@@ -14,10 +16,17 @@ public class SmoothZoom extends Module {
1416

1517
private final BindSetting zoomBind = new BindSetting("ZoomBind", Keyboard.KEY_C);
1618
private final BooleanSetting smoothMouse = new BooleanSetting("SmoothMouse", false);
19+
public static BooleanSetting smoothCamera = new BooleanSetting("smoothZoom", false);
20+
public static BooleanSetting wheelZoom = new BooleanSetting("wheelZoom", false);
21+
public static NumberSetting speed = new NumberSetting("Speed", 4.0, 0.1, 10.0, 0.1, () -> smoothCamera.getValue());
22+
23+
public static boolean using = false;
24+
public static boolean zoom = false;
25+
public static float zoomScale = 4f;
1726

1827
public SmoothZoom() {
1928
super("SmoothZoom", Category.OPTIMIZE);
20-
addSettings(smoothCamera, speed, zoomBind, smoothMouse);
29+
addSettings(smoothCamera, speed, zoomBind, smoothMouse, wheelZoom);
2130
set(true);
2231
}
2332

@@ -37,26 +46,32 @@ public void onDisable() {
3746
public void onUpdate(EventUpdate e) {
3847
if (Utility.mc.currentScreen != null) return;
3948

40-
if (Keyboard.isKeyDown(zoomBind.getValue())) {
49+
if (isZoomKeyDown()) {
50+
if(wheelZoom.getValue()){
51+
int dWheel = Mouse.getDWheel();
52+
zoomScale += dWheel / 60f;
53+
zoomScale = Math.min(Math.max(zoomScale, 2f), 20f);
54+
}
4155
zoom = true;
4256
if (smoothMouse.getValue()) {
4357
Utility.mc.gameSettings.smoothCamera = true;
4458
}
4559
} else {
4660
zoom = false;
61+
zoomScale = 4f;
4762
if (smoothMouse.getValue()) {
4863
Utility.mc.gameSettings.smoothCamera = false;
4964
}
5065
}
5166
}
5267

53-
public static boolean using = false;
54-
55-
public static boolean zoom = false;
56-
57-
public static BooleanSetting smoothCamera = new BooleanSetting("smoothZoom", false);
68+
public boolean isZoomKeyDown() {
69+
return Keyboard.isKeyDown(zoomBind.getValue());
70+
}
5871

59-
public static NumberSetting speed = new NumberSetting("Speed", 4.0, 0.1, 10.0, 0.1, () -> smoothCamera.getValue());
72+
public static boolean isZoomKeyActive() {
73+
return FPSMaster.moduleManager.getModule(SmoothZoom.class).isZoomKeyDown();
74+
}
6075
}
6176

6277

src/main/java/top/fpsmaster/forge/mixin/MixinEntityRenderer.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,29 +96,29 @@ private void getFOVModifier(float partialTicks, boolean useFOVSetting, CallbackI
9696
if (SmoothZoom.zoom) {
9797
if (useFOVSetting) {
9898
if (SmoothZoom.smoothCamera.getValue()) {
99-
screenScale = MathUtils.decreasedSpeed(screenScale, f, f / 4.0F, SmoothZoom.speed.getValue().floatValue() / (float) Minecraft.getDebugFPS() * 150.0f);
99+
screenScale = MathUtils.decreasedSpeed(screenScale, f, f / SmoothZoom.zoomScale, SmoothZoom.speed.getValue().floatValue() / (float) Minecraft.getDebugFPS() * 150.0f);
100100
} else {
101-
screenScale = f / 4.0F;
101+
screenScale = f / SmoothZoom.zoomScale;
102102
}
103103
} else {
104104
if (SmoothZoom.smoothCamera.getValue()) {
105-
screenScale2 = MathUtils.decreasedSpeed(screenScale2, f, f / 4.0F, SmoothZoom.speed.getValue().floatValue() / (float) Minecraft.getDebugFPS() * 150.0f);
105+
screenScale2 = MathUtils.decreasedSpeed(screenScale2, f, f / SmoothZoom.zoomScale, SmoothZoom.speed.getValue().floatValue() / (float) Minecraft.getDebugFPS() * 150.0f);
106106
} else {
107-
screenScale2 = f / 4.0F;
107+
screenScale2 = f / SmoothZoom.zoomScale;
108108
}
109109
}
110110
}
111111

112112
if (!SmoothZoom.zoom) {
113113
if (useFOVSetting) {
114114
if (SmoothZoom.smoothCamera.getValue()) {
115-
screenScale = MathUtils.decreasedSpeed(screenScale, f / 4.0F, f, SmoothZoom.speed.getValue().floatValue() / (float) Minecraft.getDebugFPS() * 150.0f);
115+
screenScale = MathUtils.decreasedSpeed(screenScale, f / SmoothZoom.zoomScale, f, SmoothZoom.speed.getValue().floatValue() / (float) Minecraft.getDebugFPS() * 150.0f);
116116
} else {
117117
screenScale = f;
118118
}
119119
} else {
120120
if (SmoothZoom.smoothCamera.getValue()) {
121-
screenScale2 = MathUtils.decreasedSpeed(screenScale2, f / 4.0F, f, SmoothZoom.speed.getValue().floatValue() / (float) Minecraft.getDebugFPS() * 150.0f);
121+
screenScale2 = MathUtils.decreasedSpeed(screenScale2, f / SmoothZoom.zoomScale, f, SmoothZoom.speed.getValue().floatValue() / (float) Minecraft.getDebugFPS() * 150.0f);
122122
} else {
123123
screenScale2 = f;
124124
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package top.fpsmaster.forge.mixin;
2+
3+
import net.minecraft.entity.player.InventoryPlayer;
4+
import org.spongepowered.asm.mixin.Mixin;
5+
import org.spongepowered.asm.mixin.injection.At;
6+
import org.spongepowered.asm.mixin.injection.Inject;
7+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
8+
import top.fpsmaster.features.impl.optimizes.SmoothZoom;
9+
10+
@Mixin(InventoryPlayer.class)
11+
public class MixinInventoryPlayer {
12+
@Inject(method = "changeCurrentItem", at = @At("HEAD"), cancellable = true)
13+
private void onchangeCurrentItem(int direction, CallbackInfo ci) {
14+
if (SmoothZoom.wheelZoom.getValue() && SmoothZoom.isZoomKeyActive()) {
15+
ci.cancel();
16+
}
17+
}
18+
}

src/main/resources/assets/minecraft/client/lang/en_us.lang

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,7 @@ smoothzoom.smoothzoom=Enable Smooth Zoom
565565
smoothzoom.speed=Zoom Speed
566566
smoothzoom.zoombind=Zoom Keybind
567567
smoothzoom.smoothmouse=Smooth Mouse Input
568+
smoothzoom.wheelzoom=Mouse Wheel Zoom
568569

569570
skinchanger=Skin Changer
570571
skinchanger.skin=Skin Name

src/main/resources/assets/minecraft/client/lang/zh_cn.lang

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,7 @@ smoothzoom.smoothzoom=缩放平滑
569569
smoothzoom.speed=速度
570570
smoothzoom.zoombind=快捷键
571571
smoothzoom.smoothmouse=鼠标平滑
572+
smoothzoom.wheelzoom=鼠标滚轮缩放
572573

573574
skinchanger=皮肤修改器
574575
skinchanger.skin=皮肤名称

src/main/resources/mixins.fpsmaster.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"MixinGuiNewChat",
3333
"MixinGuiPlayerOverlay",
3434
"MixinGuiScreen",
35+
"MixinInventoryPlayer",
3536
"MixinInventoryEffectRenderer",
3637
"MixinItemRenderer",
3738
"MixinKeybinding",

0 commit comments

Comments
 (0)