Skip to content

Commit

Permalink
Get 1.0.0 Ready.
Browse files Browse the repository at this point in the history
  • Loading branch information
Past Ennui committed Dec 8, 2019
1 parent e3d0c8f commit 4833da8
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 64 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
id 'maven-publish'
}

sourceCompatibility = JavaVersion.VERSION_13
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

archivesBaseName = project.archives_base_name
Expand Down
116 changes: 61 additions & 55 deletions src/main/java/io/github/joaoh1/okzoomer/OkZoomer.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public static double round(double number, int places) {
Double smoothing = 1.0 - 0.5;

Integer cinematicModeToggleCooldown = 1;
Integer timesToRepeatZoomCheck = 1;
Integer zoomProgress = 0;
Integer zoomToggleCooldown = 1;

Expand Down Expand Up @@ -81,66 +82,72 @@ public void onInitializeClient() {
} else {
minecraft.options.smoothCameraEnabled = false;
}
}

if (zoomKeyBinding.isPressed() || zoomProgress == 1) {
if (config.zoomToggle) {
zoomPressed = toggleBooleanByKeybind(zoomPressed, zoomToggleCooldown);
zoomToggleCooldown = 3;
} else {
zoomPressed = true;
}
}

if (config.smoothTransition) {
timesToRepeatZoomCheck = 4;
} else {
timesToRepeatZoomCheck = 1;
}

if (zoomPressed && zoomProgress != 2) {
smoothing = round(smoothing * 2, 4);
zoomProgress = 1;
if (!config.smoothTransition || config.zoomMultiplier == 1.0) {
smoothing = config.zoomMultiplier;
}
if (smoothing >= config.zoomMultiplier) {
smoothing = config.zoomMultiplier / config.smoothDivisor;
minecraft.options.fov = realFov * config.zoomMultiplier;
fovProcessing = false;
zoomProgress = 2;
} else {
if (config.zoomMultiplier > 1.0) {
minecraft.options.fov = realFov * (1.0 + smoothing);
} else {
minecraft.options.fov = realFov * (1.0 - smoothing);
}
for (int i = 0; i < timesToRepeatZoomCheck; i++) {
if (zoomKeyBinding.isPressed() || zoomProgress == 1) {
if (config.zoomToggle) {
zoomPressed = toggleBooleanByKeybind(zoomPressed, zoomToggleCooldown);
zoomToggleCooldown = 3;
} else {
zoomPressed = true;
}
} else if ((!zoomPressed && zoomProgress == 2)|| zoomProgress == 1) {

if (zoomPressed && zoomProgress != 2) {
smoothing = round(smoothing * 2, 4);
zoomProgress = 1;
if (!config.smoothTransition || config.zoomMultiplier == 1.0) {
smoothing = config.zoomMultiplier;
}
if (smoothing >= config.zoomMultiplier) {
smoothing = config.zoomMultiplier / config.smoothDivisor;
minecraft.options.fov = realFov;
fovProcessing = true;
zoomProgress = 0;
smoothing = config.zoomMultiplier;
}
if (smoothing >= config.zoomMultiplier) {
smoothing = config.zoomMultiplier / config.smoothDivisor;
minecraft.options.fov = realFov * config.zoomMultiplier;
fovProcessing = false;
zoomProgress = 2;
} else {
if (config.zoomMultiplier > 1.0) {
minecraft.options.fov = realFov * (config.zoomMultiplier - smoothing);
minecraft.options.fov = realFov * (1.0 + smoothing);
} else {
minecraft.options.fov = realFov * (config.zoomMultiplier + smoothing);
minecraft.options.fov = realFov * (1.0 - smoothing);
}
}
}
} else {
if (config.zoomToggle) {
zoomToggleCooldown = 1;
} else {
if (zoomProgress != 0 || !fovProcessing || zoomProgress == 1) {
} else if ((!zoomPressed && zoomProgress == 2)|| zoomProgress == 1) {
smoothing = round(smoothing * 2, 4);
zoomProgress = 1;
if (!config.smoothTransition || config.zoomMultiplier == 1.0) {
smoothing = config.zoomMultiplier;
}
if (smoothing >= config.zoomMultiplier) {
smoothing = config.zoomMultiplier / config.smoothDivisor;
minecraft.options.fov = realFov;
fovProcessing = true;
zoomProgress = 0;
} else {
if (config.zoomMultiplier > 1.0) {
minecraft.options.fov = realFov * (config.zoomMultiplier - smoothing);
} else {
minecraft.options.fov = realFov * (config.zoomMultiplier + smoothing);
}
}
}
} else {
if (config.zoomToggle) {
zoomToggleCooldown = 1;
} else if (zoomProgress != 0 || !fovProcessing || zoomProgress == 1) {
smoothing = round(smoothing * 2, 4);
zoomProgress = 0;
if (!config.smoothTransition || config.zoomMultiplier == 1.0) {
smoothing = config.zoomMultiplier;
}
if (smoothing >= config.zoomMultiplier) {
smoothing = config.zoomMultiplier / config.smoothDivisor;
minecraft.options.fov = realFov;
smoothing = config.zoomMultiplier;
}
if (smoothing >= config.zoomMultiplier) {
smoothing = config.zoomMultiplier / config.smoothDivisor;
minecraft.options.fov = realFov;
fovProcessing = true;
zoomProgress = 0;
zoomPressed = false;
Expand All @@ -149,14 +156,13 @@ public void onInitializeClient() {
} else {
minecraft.options.fov = realFov * (config.zoomMultiplier + smoothing);
}
}
}

if (fovProcessing && zoomProgress == 0) {
smoothing = config.zoomMultiplier / config.smoothDivisor;
realFov = minecraft.options.fov;
}
}
}
if (fovProcessing && zoomProgress == 0) {
smoothing = config.zoomMultiplier / config.smoothDivisor;
realFov = minecraft.options.fov;
}
}
}
});
}
}
12 changes: 6 additions & 6 deletions src/main/java/io/github/joaoh1/okzoomer/OkZoomerConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@

@Config(name = "okzoomer")
public class OkZoomerConfig implements ConfigData {
@Comment("Enables Smooth Camera while zooming, interfers with Cinematic Mode but shouldn't be anything negative.")
@Comment("Enables Smooth Camera while zooming, interfers with Cinematic Mode but it shouldn't be anything negative.")
@ConfigEntry.Gui.Tooltip(count = 2)
boolean smoothCamera = true;
@Comment("Enables Smooth Transitions when zooming in and out. WARNING: It might be prone to breakage, be careful.")
@Comment("Enables Smooth Transitions when zooming in and out.\nWARNING: It might be prone to breakage, be careful.")
@ConfigEntry.Gui.Tooltip(count = 2)
boolean smoothTransition = false;
@Comment("The divisor used while applying smoothing, less is faster, more is slower.")
@ConfigEntry.Gui.Tooltip()
int smoothDivisor = 32;
@Comment("The divisor used while applying smoothing, smaller number zooms faster, higher is slower.")
@ConfigEntry.Gui.Tooltip(count = 2)
int smoothDivisor = 64;
@Comment("Enables the ability to toggle zooming.")
@ConfigEntry.Gui.Tooltip()
boolean zoomToggle = false;
@Comment("The multiplier applied to the FOV when zooming. 1.25 is the recommended maximum,\nanything above that will break the FOV.")
@Comment("The multiplier applied to the FOV when zooming.\n1.25 is the recommended maximum, anything above that will break the FOV.")
@ConfigEntry.Gui.Tooltip(count = 3)
double zoomMultiplier = 0.5;

Expand Down
5 changes: 3 additions & 2 deletions src/main/resources/assets/okzoomer/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
"key.okzoomer.zoom": "Zoom",
"text.autoconfig.okzoomer.option.smoothCamera": "Smooth Camera",
"text.autoconfig.okzoomer.option.smoothCamera.@Tooltip[0]": "Enables Smooth Camera while zooming,",
"text.autoconfig.okzoomer.option.smoothCamera.@Tooltip[1]":"interfers with Cinematic Mode but shouldn't be anything negative.",
"text.autoconfig.okzoomer.option.smoothCamera.@Tooltip[1]":"interfers with Cinematic Mode but it shouldn't be anything negative.",
"text.autoconfig.okzoomer.option.smoothDivisor": "Smooth Zoom Divisor",
"text.autoconfig.okzoomer.option.smoothDivisor.@Tooltip": "Enables the ability to toggle zooming.",
"text.autoconfig.okzoomer.option.smoothDivisor.@Tooltip[0]": "The divisor used while applying smoothing,",
"text.autoconfig.okzoomer.option.smoothDivisor.@Tooltip[1]": "smaller number zooms faster, higher is slower.",
"text.autoconfig.okzoomer.option.zoomMultiplier": "Zoom Multiplier",
"text.autoconfig.okzoomer.option.zoomMultiplier.@Tooltip[0]": "The multiplier applied to the FOV when zooming.",
"text.autoconfig.okzoomer.option.zoomMultiplier.@Tooltip[1]": "1.25 is the recommended maximum,",
Expand Down

0 comments on commit 4833da8

Please sign in to comment.