diff options
-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.") + } + } +} |