From 7a42b12aa3bbb389dd1cdc9c1bd2d81b8a4da2bb Mon Sep 17 00:00:00 2001 From: UserTeemu <20520700+UserTeemu@users.noreply.github.com> Date: Sat, 27 Feb 2021 17:58:53 +0200 Subject: Simplify entering and exiting (#11) --- .../perspectivemod/PerspectiveMod.java | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'src/main/java/me/djtheredstoner/perspectivemod/PerspectiveMod.java') diff --git a/src/main/java/me/djtheredstoner/perspectivemod/PerspectiveMod.java b/src/main/java/me/djtheredstoner/perspectivemod/PerspectiveMod.java index 7adc1f5..dd48d4c 100644 --- a/src/main/java/me/djtheredstoner/perspectivemod/PerspectiveMod.java +++ b/src/main/java/me/djtheredstoner/perspectivemod/PerspectiveMod.java @@ -75,15 +75,13 @@ public class PerspectiveMod { public void onPressed(boolean state) { if (config.modEnabled) { if (state) { - perspectiveToggled = !perspectiveToggled; cameraYaw = mc.thePlayer.rotationYaw; cameraPitch = mc.thePlayer.rotationPitch; if (perspectiveToggled) { - previousPerspective = mc.gameSettings.thirdPersonView; - mc.gameSettings.thirdPersonView = 1; + resetPerspective(); } else { - mc.gameSettings.thirdPersonView = previousPerspective; + enterPerspective(); } } else if (config.holdMode) { resetPerspective(); @@ -93,6 +91,17 @@ public class PerspectiveMod { } } + public void enterPerspective() { + perspectiveToggled = true; + previousPerspective = mc.gameSettings.thirdPersonView; + mc.gameSettings.thirdPersonView = 1; + } + + public void resetPerspective() { + perspectiveToggled = false; + mc.gameSettings.thirdPersonView = previousPerspective; + } + public boolean overrideMouse() { if (mc.inGameHasFocus && Display.isActive()) { if (!perspectiveToggled) { @@ -120,9 +129,4 @@ public class PerspectiveMod { return false; } - - public void resetPerspective() { - perspectiveToggled = false; - mc.gameSettings.thirdPersonView = previousPerspective; - } } -- cgit