forked from hannibal002/SkyHanni
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
43 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 36 additions & 36 deletions
72
src/main/java/at/hannibal2/skyhanni/features/misc/LockMouseLook.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,36 @@ | ||
package at.hannibal2.skyhanni.features.misc | ||
|
||
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent | ||
import at.hannibal2.skyhanni.utils.LorenzUtils | ||
import net.minecraft.client.Minecraft | ||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent | ||
|
||
object LockMouseLook { | ||
private var lockedMouse = false | ||
private var oldSensitivity = 0F | ||
private val lockedPosition = -1F / 3F | ||
|
||
@SubscribeEvent | ||
fun onWorldChange(event: LorenzWorldChangeEvent) { | ||
if (lockedMouse) toggleLock() | ||
val gameSettings = Minecraft.getMinecraft().gameSettings | ||
if (gameSettings.mouseSensitivity == lockedPosition) { | ||
gameSettings.mouseSensitivity = 0.5f | ||
LorenzUtils.chat("§e[SkyHanni] §bReset your mouse sensitivity to 100%.") | ||
} | ||
} | ||
|
||
fun toggleLock() { | ||
lockedMouse = !lockedMouse | ||
|
||
val gameSettings = Minecraft.getMinecraft().gameSettings | ||
if (lockedMouse) { | ||
oldSensitivity = gameSettings.mouseSensitivity | ||
gameSettings.mouseSensitivity = lockedPosition | ||
LorenzUtils.chat("§e[SkyHanni] §bMouse rotation is now locked. Type /shmouselock to unlock your rotation") | ||
} else { | ||
gameSettings.mouseSensitivity = oldSensitivity | ||
LorenzUtils.chat("§e[SkyHanni] §bMouse rotation is now unlocked.") | ||
} | ||
} | ||
} | ||
package at.hannibal2.skyhanni.features.misc | ||
|
||
import at.hannibal2.skyhanni.SkyHanniMod | ||
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent | ||
import at.hannibal2.skyhanni.utils.LorenzUtils | ||
import net.minecraft.client.Minecraft | ||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent | ||
|
||
object LockMouseLook { | ||
private var lockedMouse = false | ||
private const val lockedPosition = -1F / 3F | ||
|
||
@SubscribeEvent | ||
fun onWorldChange(event: LorenzWorldChangeEvent) { | ||
if (lockedMouse) toggleLock() | ||
val gameSettings = Minecraft.getMinecraft().gameSettings | ||
if (gameSettings.mouseSensitivity == lockedPosition) { | ||
gameSettings.mouseSensitivity = SkyHanniMod.feature.storage.savedMouseSensitivity | ||
LorenzUtils.chat("§e[SkyHanni] §bMouse rotation is now unlocked because you left it locked.") | ||
} | ||
} | ||
|
||
fun toggleLock() { | ||
val gameSettings = Minecraft.getMinecraft().gameSettings ?: return | ||
lockedMouse = !lockedMouse | ||
|
||
if (lockedMouse) { | ||
SkyHanniMod.feature.storage.savedMouseSensitivity = gameSettings.mouseSensitivity | ||
gameSettings.mouseSensitivity = lockedPosition | ||
LorenzUtils.chat("§e[SkyHanni] §bMouse rotation is now locked. Type /shmouselock to unlock your rotation") | ||
} else { | ||
gameSettings.mouseSensitivity = SkyHanniMod.feature.storage.savedMouseSensitivity | ||
LorenzUtils.chat("§e[SkyHanni] §bMouse rotation is now unlocked.") | ||
} | ||
} | ||
} |