Skip to content

Commit

Permalink
Add /shmouselock command to lock mouse rotation for farming (#470)
Browse files Browse the repository at this point in the history
Add /shmouselock command to lock mouse rotation for farming #470
  • Loading branch information
brandonwamboldt authored Oct 17, 2023
1 parent 75624d6 commit 64d038a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -603,6 +604,7 @@ class SkyHanniMod {
loadModule(LimboTimeTracker())
loadModule(PartyMemberOutlines())
loadModule(ShiftClickEquipment())
loadModule(LockMouseLook)

init()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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() {
Expand Down
29 changes: 29 additions & 0 deletions src/main/java/at/hannibal2/skyhanni/features/misc/LockMouseLook.kt
Original file line number Diff line number Diff line change
@@ -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.")
}
}
}

0 comments on commit 64d038a

Please sign in to comment.