Skip to content

Commit d4666c0

Browse files
committed
fix zoom not working when sprinting while using java dynamic fov
1 parent 979c1cb commit d4666c0

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

src/Client/Module/Modules/JavaDynamicFOV/JavaDynamicFOV.hpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include "../Module.hpp"
44
#include "../../../../SDK/Client/Core/Options.hpp"
5-
5+
#include "../Zoom/Zoom.hpp"
66

77
class JavaDynamicFOV : public Module {
88
private:
@@ -13,8 +13,8 @@ class JavaDynamicFOV : public Module {
1313

1414
static inline bool firstTime = true;
1515

16-
static inline bool animationFinished = false;
1716
public:
17+
static inline bool animationFinished = true;
1818
JavaDynamicFOV() : Module("Java Dynamic FOV", "Enhances dynamic FOV in bedrock.", IDR_MAGNIFY_PNG, "C") {
1919
Module::setup();
2020
};
@@ -68,6 +68,10 @@ class JavaDynamicFOV : public Module {
6868
if(fov == 70) return;
6969
realFov = fov;
7070

71+
if (ModuleManager::getModule("Zoom").get()->active || !Zoom::animationFinished)
72+
{
73+
return;
74+
}
7175
if(firstTime){ // so that it doesn't unzoom on module load
7276
currentFOVVal = fov;
7377
firstTime = false;
@@ -84,19 +88,19 @@ class JavaDynamicFOV : public Module {
8488
bool alwaysanim = false;
8589

8690
if (player->getActorFlag(ActorFlags::FLAG_SPRINTING)) {
87-
animationFinished = false;
91+
Zoom::jdfAnimationFinished = false;
8892
if (fov > 180) {
8993
currentFOVVal = disableanim ? fov + fovTarget : std::lerp(currentFOVVal, fov + fovTarget, animspeed * FlarialGUI::frameFactor);
9094
} else {
9195
currentFOVVal = disableanim ? fovTarget : std::lerp(currentFOVVal, fovTarget, animspeed * FlarialGUI::frameFactor);
9296
}
9397
} else {
94-
if ((!animationFinished || alwaysanim) && !disableanim) {
98+
if ((!Zoom::jdfAnimationFinished || alwaysanim) && !disableanim) {
9599
// Only lerp if animation hasn't finished
96100
currentFOVVal = std::lerp(currentFOVVal, fov, animspeed * FlarialGUI::frameFactor);
97101
if (currentFOVVal == fovTarget || std::abs(fov - currentFOVVal) < animspeed + animDisableTreshold) { // when fov changes due to sprinting animation used to play
98102
// Set animationFinished to true only when reaching original fov
99-
animationFinished = true;
103+
Zoom::jdfAnimationFinished = true;
100104
}
101105
} else {
102106
currentFOVVal = fov;

src/Client/Module/Modules/Zoom/Zoom.hpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ class Zoom : public Module {
1616

1717
static inline bool fisrtTime = true;
1818

19-
static inline bool animationFinished = false;
2019
public:
20+
static inline bool animationFinished = true;
21+
static inline bool jdfAnimationFinished = true;
2122
Zoom() : Module("Zoom", "Allows you to see distant places.", IDR_MAGNIFY_PNG, "C") {
2223
Module::setup();
2324
};
@@ -88,7 +89,14 @@ class Zoom : public Module {
8889
void onGetFOV(FOVEvent &event) {
8990
auto fov = event.getFOV();
9091
if(fov == 70) return;
91-
realFov = fov;
92+
93+
auto player = SDK::clientInstance->getLocalPlayer();
94+
if (!player) return;
95+
96+
if (player->getActorFlag(ActorFlags::FLAG_SPRINTING))
97+
{
98+
fov = ModuleManager::getModule("Java Dynamic FOV").get()->settings.getSettingByName<float>("fov_target")->value;
99+
}
92100

93101
if(fisrtTime){ // so that it doesn't unzoom on module load
94102
currentZoomVal = fov;
@@ -110,6 +118,10 @@ class Zoom : public Module {
110118
} else {
111119
if ((!animationFinished || alwaysanim) && !disableanim) {
112120
// Only lerp if animation hasn't finished
121+
if (!jdfAnimationFinished)
122+
{
123+
jdfAnimationFinished = true;
124+
}
113125
currentZoomVal = std::lerp(currentZoomVal, fov, animspeed * FlarialGUI::frameFactor);
114126
if (currentZoomVal == zoomValue || std::abs(fov - currentZoomVal) < animspeed + unzoomAnimDisableTreshold) { // when fov changes due to sprinting animation used to play
115127
// Set animationFinished to true only when reaching original fov

0 commit comments

Comments
 (0)