aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-08-19 09:50:51 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-08-19 09:50:51 +0200
commit3c9a36985344f748628c763c1898452727a8d4cc (patch)
treec771709386134a3ca2bc4be2d1934211a0efbfcd /src/main/java/at/hannibal2
parent454c1e59167851b40b9d7a6fccd75d7bedcf194c (diff)
downloadskyhanni-3c9a36985344f748628c763c1898452727a8d4cc.tar.gz
skyhanni-3c9a36985344f748628c763c1898452727a8d4cc.tar.bz2
skyhanni-3c9a36985344f748628c763c1898452727a8d4cc.zip
Replacing Keyboard.isKeyDown and KeybindHelper.isKeyDown with OSUtils.isKeyHeld
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt1
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/FishingTimer.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishFillet.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/ToolTooltipTweaks.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCustomKeybinds.kt14
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/ChatPeek.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/HarpFeatures.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/PasteIntoSigns.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/TestExportTools.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/TestShowSlotNumber.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/OSUtils.kt15
16 files changed, 41 insertions, 38 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index b998e7f07..d66d4f69b 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -392,6 +392,7 @@ class SkyHanniMod {
loadModule(TestCopyBestiaryValues)
loadModule(HighlightMissingRepoItems())
loadModule(ParkourWaypointSaver())
+ loadModule(TestShowSlotNumber())
}
@Mod.EventHandler
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 9347d1580..ae821f60f 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
@@ -9,7 +9,6 @@ import at.hannibal2.skyhanni.utils.*
import at.hannibal2.skyhanni.utils.LorenzUtils.editCopy
import at.hannibal2.skyhanni.utils.StringUtils.cleanPlayerName
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
-import io.github.moulberry.moulconfig.internal.KeybindHelper
import net.minecraft.client.Minecraft
import net.minecraft.client.entity.EntityOtherPlayerMP
import net.minecraft.network.play.server.S02PacketChat
@@ -133,7 +132,7 @@ object InquisitorWaypointShare {
// add repo kill switch
sendInquisitor()
} else {
- val keyName = KeybindHelper.getKeyName(config.keyBindShare)
+ val keyName = OSUtils.getKeyName(config.keyBindShare)
val message =
"§e[SkyHanni] §l§bYou found a Inquisitor! Press §l§chere §l§bor §c$keyName to share the location!"
LorenzUtils.clickableChat(message, "shshareinquis")
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingTimer.kt
index c97ca4ed8..f5f87ee2c 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingTimer.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingTimer.kt
@@ -9,7 +9,6 @@ import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland
import at.hannibal2.skyhanni.utils.RenderUtils.renderString
import net.minecraft.entity.item.EntityArmorStand
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
-import org.lwjgl.input.Keyboard
class FishingTimer {
private val config get() = SkyHanniMod.feature.fishing
@@ -33,7 +32,7 @@ class FishingTimer {
if (event.isMod(5)) checkMobs()
if (event.isMod(7)) tryPlaySound()
- if (Keyboard.isKeyDown(config.manualResetTimer)) startTime = System.currentTimeMillis()
+ if (OSUtils.isKeyHeld(config.manualResetTimer)) startTime = System.currentTimeMillis()
}
private fun tryPlaySound() {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishFillet.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishFillet.kt
index 18dfc5d7d..edb9d9fd1 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishFillet.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishFillet.kt
@@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.NEUItems
import at.hannibal2.skyhanni.utils.NumberUtil
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
+import at.hannibal2.skyhanni.utils.OSUtils
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import org.lwjgl.input.Keyboard
@@ -22,7 +23,7 @@ class TrophyFishFillet {
val trophyRarityName = internalName.substringAfterLast("_")
val info = TrophyFishManager.getInfo(trophyFishName) ?: return
val rarity = TrophyRarity.getByName(trophyRarityName) ?: return
- val multiplier = if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) event.itemStack.stackSize else 1
+ val multiplier = if (OSUtils.isKeyHeld(Keyboard.KEY_LSHIFT)) event.itemStack.stackSize else 1
val filletValue = info.getFilletValue(rarity) * multiplier
val filletPrice = filletValue * NEUItems.getPrice("MAGMA_FISH")
event.toolTip.add("§7Fillet: §8${filletValue.addSeparators()} Magmafish §7(§6${NumberUtil.format(filletPrice)}§7)")
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/ToolTooltipTweaks.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/ToolTooltipTweaks.kt
index 86b7f5251..759f9f0ec 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/ToolTooltipTweaks.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/ToolTooltipTweaks.kt
@@ -7,12 +7,12 @@ import at.hannibal2.skyhanni.features.garden.GardenAPI.getCropType
import at.hannibal2.skyhanni.features.garden.fortuneguide.FFGuideGUI
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.OSUtils
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getFarmingForDummiesCount
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getReforgeName
import at.hannibal2.skyhanni.utils.StringUtils.firstLetterUppercase
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
-import org.lwjgl.input.Keyboard
import java.text.DecimalFormat
import kotlin.math.roundToInt
@@ -82,7 +82,7 @@ class ToolTooltipTweaks {
}
iterator.set(fortuneLine)
- if (Keyboard.isKeyDown(config.fortuneTooltipKeybind)) {
+ if (OSUtils.isKeyHeld(config.fortuneTooltipKeybind)) {
iterator.addStat(" §7Base: §6+", baseFortune)
iterator.addStat(" §7Tool: §6+", toolFortune)
iterator.addStat(" §7${reforgeName?.removeColor()}: §9+", reforgeFortune)
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCustomKeybinds.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCustomKeybinds.kt
index 41d88190f..40a2aa12e 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCustomKeybinds.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCustomKeybinds.kt
@@ -3,11 +3,10 @@ package at.hannibal2.skyhanni.features.garden.farming
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.features.garden.GardenAPI
import at.hannibal2.skyhanni.mixins.transformers.AccessorKeyBinding
+import at.hannibal2.skyhanni.utils.OSUtils
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.inventory.GuiEditSign
import net.minecraft.client.settings.KeyBinding
-import org.lwjgl.input.Keyboard
-import org.lwjgl.input.Mouse
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable
import java.util.*
@@ -49,21 +48,12 @@ object GardenCustomKeybinds {
return true
}
- private fun isHeld(keyCode: Int): Boolean {
- if (keyCode == 0) return false
- return if (keyCode < 0) {
- Mouse.isButtonDown(keyCode + 100)
- } else {
- Keyboard.isKeyDown(keyCode)
- }
- }
-
@JvmStatic
fun isKeyDown(keyBinding: KeyBinding, cir: CallbackInfoReturnable<Boolean>) {
if (!isActive()) return
val override = map[keyBinding] ?: return
val keyCode = override()
- cir.returnValue = isHeld(keyCode)
+ cir.returnValue = OSUtils.isKeyHeld(keyCode)
}
@JvmStatic
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt
index e5d3a89f4..13ff0ecfa 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt
@@ -26,7 +26,6 @@ import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.renderables.Renderable
-import io.github.moulberry.moulconfig.internal.KeybindHelper
import io.github.moulberry.notenoughupdates.events.SlotClickEvent
import io.github.moulberry.notenoughupdates.util.MinecraftExecutor
import net.minecraft.client.Minecraft
@@ -277,7 +276,7 @@ class GardenVisitorFeatures {
visitor.hasReward()?.let {
if (config.visitorRewardWarning.preventRefusing) {
- if (KeybindHelper.isKeyDown(config.visitorRewardWarning.bypassKey)) {
+ if (OSUtils.isKeyHeld(config.visitorRewardWarning.bypassKey)) {
LorenzUtils.chat("§e[SkyHanni] §cBypassed blocking refusal of visitor ${visitor.visitorName} §7(${it.displayName}§7)")
return
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ChatPeek.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ChatPeek.kt
index 6d3dfdb8f..efc6e3d1e 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/ChatPeek.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ChatPeek.kt
@@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.misc
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.utils.NEUItems
+import at.hannibal2.skyhanni.utils.OSUtils
import io.github.moulberry.moulconfig.gui.GuiScreenElementWrapper
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.inventory.GuiEditSign
@@ -20,6 +21,6 @@ object ChatPeek {
if (NEUItems.neuHasFocus()) return false
- return Keyboard.isKeyDown(key)
+ return OSUtils.isKeyHeld(key)
}
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/HarpFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/HarpFeatures.kt
index 3c3911f9a..b05908f9d 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/HarpFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/HarpFeatures.kt
@@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.RenderItemTipEvent
import at.hannibal2.skyhanni.utils.InventoryUtils.openInventoryName
import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.OSUtils
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.inventory.GuiChest
@@ -38,7 +39,7 @@ class HarpFeatures {
val chest = event.gui as? GuiChest ?: return
for (key in keys) {
- if (Keyboard.isKeyDown(key)) {
+ if (OSUtils.isKeyHeld(key)) {
if (lastClick.passedSince() > 200.milliseconds) {
Minecraft.getMinecraft().playerController.windowClick(
chest.inventorySlots.windowId,
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/PasteIntoSigns.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/PasteIntoSigns.kt
index ba797ff74..bdddcc3a7 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/PasteIntoSigns.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/PasteIntoSigns.kt
@@ -15,7 +15,7 @@ class PasteIntoSigns {
if (!LorenzUtils.onHypixel) return
if (!SkyHanniMod.feature.misc.pasteIntoSigns) return
- if (LorenzUtils.isControlKeyDown() && Keyboard.isKeyDown(Keyboard.KEY_V)) {
+ if (LorenzUtils.isControlKeyDown() && OSUtils.isKeyHeld(Keyboard.KEY_V)) {
SkyHanniMod.coroutineScope.launch {
OSUtils.readFromClipboard()?.let {
LorenzUtils.setTextIntoSign(it.take(15))
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt
index 58616196f..464b45762 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt
@@ -21,6 +21,7 @@ import at.hannibal2.skyhanni.utils.NEUItems.getPrice
import at.hannibal2.skyhanni.utils.NEUItems.getPriceOrNull
import at.hannibal2.skyhanni.utils.NumberUtil
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
+import at.hannibal2.skyhanni.utils.OSUtils
import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getAbilityScrolls
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getArmorDye
@@ -48,7 +49,6 @@ import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.hasWoodSingularity
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.isRecombobulated
import at.hannibal2.skyhanni.utils.StringUtils.firstLetterUppercase
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
-import io.github.moulberry.moulconfig.internal.KeybindHelper
import io.github.moulberry.notenoughupdates.util.Constants
import net.minecraft.init.Items
import net.minecraft.item.ItemStack
@@ -65,7 +65,7 @@ object EstimatedItemValue {
fun onRenderOverlay(event: GuiRenderEvent.ChestBackgroundRenderEvent) {
if (!LorenzUtils.inSkyBlock) return
if (!config.estimatedIemValueEnabled) return
- if (!KeybindHelper.isKeyDown(config.estimatedItemValueHotkey) && !config.estimatedIemValueAlwaysEnabled) return
+ if (!OSUtils.isKeyHeld(config.estimatedItemValueHotkey) && !config.estimatedIemValueAlwaysEnabled) return
if (System.currentTimeMillis() > lastToolTipTime + 200) return
config.itemPriceDataPos.renderStringsAndItems(display, posLabel = "Estimated Item Value")
diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt
index 2efc657bf..156062432 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt
@@ -13,12 +13,12 @@ import at.hannibal2.skyhanni.features.nether.reputationhelper.miniboss.DailyMini
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList
import at.hannibal2.skyhanni.utils.LorenzVec
+import at.hannibal2.skyhanni.utils.OSUtils
import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
import at.hannibal2.skyhanni.utils.TabListData
import com.google.gson.JsonObject
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
-import org.lwjgl.input.Keyboard
class CrimsonIsleReputationHelper(skyHanniMod: SkyHanniMod) {
val config get() = SkyHanniMod.feature.misc
@@ -112,7 +112,7 @@ class CrimsonIsleReputationHelper(skyHanniMod: SkyHanniMod) {
if (LorenzUtils.skyBlockIsland != IslandType.CRIMSON_ISLE) return
if (config.reputationHelperUseHotkey) {
- if (!Keyboard.isKeyDown(config.reputationHelperHotkey)) {
+ if (!OSUtils.isKeyHeld(config.reputationHelperHotkey)) {
return
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/test/TestExportTools.kt b/src/main/java/at/hannibal2/skyhanni/test/TestExportTools.kt
index e3df5c54c..7ae608d51 100644
--- a/src/main/java/at/hannibal2/skyhanni/test/TestExportTools.kt
+++ b/src/main/java/at/hannibal2/skyhanni/test/TestExportTools.kt
@@ -9,7 +9,6 @@ import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound
import net.minecraftforge.client.event.GuiScreenEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
-import org.lwjgl.input.Keyboard
import java.io.InputStreamReader
import java.io.Reader
@@ -41,8 +40,8 @@ object TestExportTools {
}
@SubscribeEvent
- fun onKeybind(event: GuiScreenEvent.KeyboardInputEvent) {
- if (!Keyboard.isKeyDown(SkyHanniMod.feature.dev.copyNBTDataCompressed)) return
+ fun onKeybind(event: GuiScreenEvent.KeyboardInputEvent.Post) {
+ if (!OSUtils.isKeyHeld(SkyHanniMod.feature.dev.copyNBTDataCompressed)) return
val gui = event.gui as? GuiContainer ?: return
val focussedSlot = gui.slotUnderMouse ?: return
val stack = focussedSlot.stack ?: return
diff --git a/src/main/java/at/hannibal2/skyhanni/test/TestShowSlotNumber.kt b/src/main/java/at/hannibal2/skyhanni/test/TestShowSlotNumber.kt
index be202e20d..115cef414 100644
--- a/src/main/java/at/hannibal2/skyhanni/test/TestShowSlotNumber.kt
+++ b/src/main/java/at/hannibal2/skyhanni/test/TestShowSlotNumber.kt
@@ -2,14 +2,14 @@ package at.hannibal2.skyhanni.test
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.RenderInventoryItemTipEvent
+import at.hannibal2.skyhanni.utils.OSUtils
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
-import org.lwjgl.input.Keyboard
class TestShowSlotNumber {
@SubscribeEvent
fun onRenderItemTip(event: RenderInventoryItemTipEvent) {
- if (Keyboard.isKeyDown(SkyHanniMod.feature.dev.showSlotNumberKey)) {
+ if (OSUtils.isKeyHeld(SkyHanniMod.feature.dev.showSlotNumberKey)) {
val slotIndex = event.slot.slotIndex
event.stackTip = "$slotIndex"
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
index 71dfb1edb..4641c566c 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
@@ -267,9 +267,9 @@ object LorenzUtils {
}
}
- fun isShiftKeyDown() = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)
+ fun isShiftKeyDown() = OSUtils.isKeyHeld(Keyboard.KEY_LSHIFT) || OSUtils.isKeyHeld(Keyboard.KEY_RSHIFT)
- fun isControlKeyDown() = Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL)
+ fun isControlKeyDown() = OSUtils.isKeyHeld(Keyboard.KEY_LCONTROL) || OSUtils.isKeyHeld(Keyboard.KEY_RCONTROL)
// MoulConfig is in Java, I don't want to downgrade this logic
fun <T> onChange(vararg properties: Property<out T>, observer: Observer<T>) {
@@ -409,8 +409,8 @@ object LorenzUtils {
val tileSign = (this as AccessorGuiEditSign).tileSign
return (tileSign.signText[1].unformattedText.removeColor() == "^^^^^^"
- && tileSign.signText[2].unformattedText.removeColor() == "Set your"
- && tileSign.signText[3].unformattedText.removeColor() == "speed cap!")
+ && tileSign.signText[2].unformattedText.removeColor() == "Set your"
+ && tileSign.signText[3].unformattedText.removeColor() == "speed cap!")
}
fun inIsland(island: IslandType) = inSkyBlock && skyBlockIsland == island
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/OSUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/OSUtils.kt
index 254d8ad09..981ea87c3 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/OSUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/OSUtils.kt
@@ -1,7 +1,9 @@
package at.hannibal2.skyhanni.utils
+import io.github.moulberry.moulconfig.internal.KeybindHelper
import net.minecraft.client.settings.KeyBinding
import org.lwjgl.input.Keyboard
+import org.lwjgl.input.Mouse
import java.awt.Desktop
import java.io.IOException
import java.net.URI
@@ -32,7 +34,7 @@ object OSUtils {
fun KeyBinding.isActive(): Boolean {
if (!Keyboard.isCreated()) return false
try {
- if (Keyboard.isKeyDown(this.keyCode)) return true
+ if (isKeyHeld(keyCode)) return true
} catch (e: IndexOutOfBoundsException) {
println("KeyBinding isActive caused an IndexOutOfBoundsException with keyCode: $keyCode")
e.printStackTrace()
@@ -40,4 +42,15 @@ object OSUtils {
}
return this.isKeyDown || this.isPressed
}
+
+ fun isKeyHeld(keyCode: Int): Boolean {
+ if (keyCode == 0) return false
+ return if (keyCode < 0) {
+ Mouse.isButtonDown(keyCode + 100)
+ } else {
+ KeybindHelper.isKeyDown(keyCode)
+ }
+ }
+
+ fun getKeyName(keyCode: Int): String = KeybindHelper.getKeyName(keyCode)
}