diff options
| author | CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> | 2023-10-12 22:31:49 +1100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-12 13:31:49 +0200 |
| commit | db0cd17c7019c072a5043ae8d0dca8ce6459fb32 (patch) | |
| tree | 3e8a33b6d434d02d637e596eecd707d4e8c17495 /src/main/java/at/hannibal2/skyhanni/features/event | |
| parent | d4084e697899f6dc3ceb87b4d229e0fe3819440a (diff) | |
| download | skyhanni-db0cd17c7019c072a5043ae8d0dca8ce6459fb32.tar.gz skyhanni-db0cd17c7019c072a5043ae8d0dca8ce6459fb32.tar.bz2 skyhanni-db0cd17c7019c072a5043ae8d0dca8ce6459fb32.zip | |
Fix + Backend: Made mouse buttons work as key binds (#560)
Fix + Backend: Made mouse buttons work as key binds #560
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/event')
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt | 29 | ||||
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt | 11 |
2 files changed, 16 insertions, 24 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt index f96c6d260..afbf7e16b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt @@ -3,34 +3,33 @@ package at.hannibal2.skyhanni.features.event.diana import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.LorenzKeyPressEvent import at.hannibal2.skyhanni.utils.LocationUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.sorted import at.hannibal2.skyhanni.utils.LorenzVec +import at.hannibal2.skyhanni.utils.SimpleTimeMark import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.InputEvent.KeyInputEvent -import org.lwjgl.input.Keyboard +import kotlin.time.Duration.Companion.seconds class BurrowWarpHelper { - private var lastWarpTime = 0L + private var lastWarpTime = SimpleTimeMark.farPast() private var lastWarp: WarpPoint? = null @SubscribeEvent - fun onKeyBindPressed(event: KeyInputEvent) { + fun onKeyClick(event: LorenzKeyPressEvent) { if (!LorenzUtils.inSkyBlock) return if (LorenzUtils.skyBlockIsland != IslandType.HUB) return if (!config.burrowNearestWarp) return - if (!Keyboard.getEventKeyState()) return - val key = if (Keyboard.getEventKey() == 0) Keyboard.getEventCharacter().code + 256 else Keyboard.getEventKey() - if (config.keyBindWarp == key) { - currentWarp?.let { - if (System.currentTimeMillis() > lastWarpTime + 5_000) { - lastWarpTime = System.currentTimeMillis() - LorenzUtils.sendCommandToServer("warp " + currentWarp?.name) - lastWarp = currentWarp - } + if (event.keyCode != config.keyBindWarp) return + + currentWarp?.let { + if (lastWarpTime.passedSince() < 5.seconds) { + lastWarpTime = SimpleTimeMark.now() + LorenzUtils.sendCommandToServer("warp " + currentWarp?.name) + lastWarp = currentWarp } } } @@ -40,8 +39,7 @@ class BurrowWarpHelper { if (!LorenzUtils.inSkyBlock) return if (event.message == "§cYou haven't unlocked this fast travel destination!") { - val time = System.currentTimeMillis() - lastWarpTime - if (time < 1_000) { + if (lastWarpTime.passedSince() < 1.seconds) { lastWarp?.let { it.unlocked = false LorenzUtils.chat( @@ -53,7 +51,6 @@ class BurrowWarpHelper { } } } - } companion object { diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt index 8c139c923..caf2cb014 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.EntityHealthUpdateEvent import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.LorenzKeyPressEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.PacketEvent @@ -25,8 +26,6 @@ import net.minecraft.network.play.server.S02PacketChat import net.minecraftforge.event.entity.EntityJoinWorldEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.InputEvent -import org.lwjgl.input.Keyboard import kotlin.time.Duration.Companion.seconds object InquisitorWaypointShare { @@ -164,13 +163,9 @@ object InquisitorWaypointShare { } @SubscribeEvent - fun onKeyBindPressed(event: InputEvent.KeyInputEvent) { + fun onKeyClick(event: LorenzKeyPressEvent) { if (!isEnabled()) return - if (!Keyboard.getEventKeyState()) return - val key = if (Keyboard.getEventKey() == 0) Keyboard.getEventCharacter().code + 256 else Keyboard.getEventKey() - if (config.keyBindShare == key) { - sendInquisitor() - } + if (event.keyCode == config.keyBindShare) sendInquisitor() } private fun sendDeath() { |
