diff options
author | Brandon <brandon.wamboldt@gmail.com> | 2023-10-17 07:08:55 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-17 12:08:55 +0200 |
commit | 64d038a41492cd7621dd8cbf326cda9200d5cc81 (patch) | |
tree | a60da0187f8a01d7f0acf1831efbb3628e9de50f /src/main/java/at/hannibal2/skyhanni | |
parent | 75624d65238a305872b61b43a8b94584a98f657c (diff) | |
download | skyhanni-64d038a41492cd7621dd8cbf326cda9200d5cc81.tar.gz skyhanni-64d038a41492cd7621dd8cbf326cda9200d5cc81.tar.bz2 skyhanni-64d038a41492cd7621dd8cbf326cda9200d5cc81.zip |
Add /shmouselock command to lock mouse rotation for farming (#470)
Add /shmouselock command to lock mouse rotation for farming #470
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
3 files changed, 36 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index cb85a3fd6..ce7ad3490 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -181,6 +181,7 @@ import at.hannibal2.skyhanni.features.misc.HideDamageSplash import at.hannibal2.skyhanni.features.misc.InGameDateDisplay import at.hannibal2.skyhanni.features.misc.JoinCrystalHollows import at.hannibal2.skyhanni.features.misc.LimboTimeTracker +import at.hannibal2.skyhanni.features.misc.LockMouseLook import at.hannibal2.skyhanni.features.misc.MarkedPlayerManager import at.hannibal2.skyhanni.features.misc.MiscFeatures import at.hannibal2.skyhanni.features.misc.MovementSpeedDisplay @@ -603,6 +604,7 @@ class SkyHanniMod { loadModule(LimboTimeTracker()) loadModule(PartyMemberOutlines()) loadModule(ShiftClickEquipment()) + loadModule(LockMouseLook) init() diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt index 1479e5037..ca6018ad6 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -24,6 +24,7 @@ import at.hannibal2.skyhanni.features.garden.fortuneguide.CaptureFarmingGear import at.hannibal2.skyhanni.features.garden.fortuneguide.FFGuideGUI import at.hannibal2.skyhanni.features.minion.MinionFeatures import at.hannibal2.skyhanni.features.misc.CollectionTracker +import at.hannibal2.skyhanni.features.misc.LockMouseLook import at.hannibal2.skyhanni.features.misc.MarkedPlayerManager import at.hannibal2.skyhanni.features.misc.discordrpc.DiscordRPCManager import at.hannibal2.skyhanni.features.misc.ghostcounter.GhostUtil @@ -164,6 +165,10 @@ object Commands { // "Copies the translation for a given message to your clipboard. " + // "Language codes are at the end of the translation when you click on a message." // ) { Translator.fromEnglish(it) } + registerCommand( + "shmouselock", + "Lock/Unlock the mouse so it will no longer rotate the player (for farming)" + ) { LockMouseLook.toggleLock() } } private fun usersBugFix() { diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/LockMouseLook.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/LockMouseLook.kt new file mode 100644 index 000000000..8058ec2c0 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/LockMouseLook.kt @@ -0,0 +1,29 @@ +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;
+
+ @SubscribeEvent
+ fun onWorldChange(event: LorenzWorldChangeEvent) {
+ if (lockedMouse) toggleLock()
+ }
+
+ fun toggleLock() {
+ lockedMouse = !lockedMouse
+
+ if (lockedMouse) {
+ oldSensitivity = Minecraft.getMinecraft().gameSettings.mouseSensitivity;
+ Minecraft.getMinecraft().gameSettings.mouseSensitivity = -1F/3F;
+ LorenzUtils.chat("§b[SkyHanni] Mouse rotation is now locked. Type /shmouselock to unlock your rotation")
+ } else {
+ Minecraft.getMinecraft().gameSettings.mouseSensitivity = oldSensitivity
+ LorenzUtils.chat("§b[SkyHanni] Mouse rotation is now unlocked.")
+ }
+ }
+}
\ No newline at end of file |