diff options
author | CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> | 2023-11-03 06:48:51 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-02 20:48:51 +0100 |
commit | 2ce84766100584a5aaf516a2cbf0907585aaa07e (patch) | |
tree | f3451f548165cace76686caddb82ef5b3552776f /src/main/java | |
parent | ec2d189ede2487a98943339fa7816a0e948e7a90 (diff) | |
download | skyhanni-2ce84766100584a5aaf516a2cbf0907585aaa07e.tar.gz skyhanni-2ce84766100584a5aaf516a2cbf0907585aaa07e.tar.bz2 skyhanni-2ce84766100584a5aaf516a2cbf0907585aaa07e.zip |
actually fix mouse locking (#662)
Fixed mouse sensitivity stuck after restarting by storing old sensitivity. #662
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/config/Storage.java | 11 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/misc/LockMouseLook.kt | 72 |
2 files changed, 43 insertions, 40 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/Storage.java b/src/main/java/at/hannibal2/skyhanni/config/Storage.java index 21ed83b00..a63477a07 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/Storage.java +++ b/src/main/java/at/hannibal2/skyhanni/config/Storage.java @@ -1,16 +1,16 @@ package at.hannibal2.skyhanni.config; import at.hannibal2.skyhanni.data.model.ComposterUpgrade; +import at.hannibal2.skyhanni.features.combat.endernodetracker.EnderNode; +import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostData; import at.hannibal2.skyhanni.features.dungeon.DungeonAPI; +import at.hannibal2.skyhanni.features.event.jerry.frozentreasure.FrozenTreasure; import at.hannibal2.skyhanni.features.fishing.trophy.TrophyRarity; import at.hannibal2.skyhanni.features.garden.CropAccessory; import at.hannibal2.skyhanni.features.garden.CropType; import at.hannibal2.skyhanni.features.garden.farming.FarmingArmorDrops; import at.hannibal2.skyhanni.features.garden.fortuneguide.FarmingItems; import at.hannibal2.skyhanni.features.garden.visitor.VisitorReward; -import at.hannibal2.skyhanni.features.combat.endernodetracker.EnderNode; -import at.hannibal2.skyhanni.features.event.jerry.frozentreasure.FrozenTreasure; -import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostData; import at.hannibal2.skyhanni.features.mining.powdertracker.PowderChestReward; import at.hannibal2.skyhanni.features.misc.trevor.TrevorTracker; import at.hannibal2.skyhanni.features.misc.visualwords.VisualWord; @@ -32,6 +32,9 @@ public class Storage { public boolean hasPlayedBefore = false; @Expose + public Float savedMouseSensitivity = .5f; + + @Expose public Map<String, List<String>> knownFeatureToggles = new HashMap<>(); @Expose @@ -457,4 +460,4 @@ public class Storage { public Map<DungeonAPI.DungeonFloor, Integer> bosses = new HashMap<>(); } } -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/LockMouseLook.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/LockMouseLook.kt index 8873c7402..b4ab08459 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/LockMouseLook.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/LockMouseLook.kt @@ -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.") + } + } +} |