Skip to content

Commit

Permalink
Reset mouse sensitivity back to 100% if you log off with lock mouse l…
Browse files Browse the repository at this point in the history
…ook enabled.
  • Loading branch information
hannibal002 committed Nov 1, 2023
1 parent 1d4e3a5 commit ad12389
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@ 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() {
Expand All @@ -20,11 +26,11 @@ object LockMouseLook {
val gameSettings = Minecraft.getMinecraft().gameSettings
if (lockedMouse) {
oldSensitivity = gameSettings.mouseSensitivity
gameSettings.mouseSensitivity = -1F / 3F
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.")
}
}
}
}

0 comments on commit ad12389

Please sign in to comment.