diff --git a/src/main/kotlin/com/github/stivais/ui/UIScreen.kt b/src/main/kotlin/com/github/stivais/ui/UIScreen.kt index f640ae619..a4c18e1c8 100644 --- a/src/main/kotlin/com/github/stivais/ui/UIScreen.kt +++ b/src/main/kotlin/com/github/stivais/ui/UIScreen.kt @@ -5,6 +5,7 @@ import me.odinmain.OdinMain.mc import net.minecraft.client.gui.GuiScreen import net.minecraftforge.client.event.RenderWorldLastEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import org.lwjgl.input.Keyboard import org.lwjgl.input.Mouse import org.lwjgl.opengl.Display @@ -12,6 +13,7 @@ open class UIScreen(val ui: UI) : GuiScreen(), Window { private var previousWidth: Int = 0 private var previousHeight: Int = 0 + private val pressedKeys = mutableSetOf() fun close() { if (mc.currentScreen == null) { @@ -52,6 +54,13 @@ open class UIScreen(val ui: UI) : GuiScreen(), Window { } ui.render() } + + for (key in pressedKeys.toList()) { + if (!Keyboard.isKeyDown(key)) { + ui.eventManager.onKeyReleased(key) + pressedKeys.remove(key) + } + } } override fun handleMouseInput() { @@ -72,18 +81,13 @@ open class UIScreen(val ui: UI) : GuiScreen(), Window { override fun keyTyped(typedChar: Char, keyCode: Int) { if (ui.eventManager.onKeyType(typedChar)) return - if (ui.eventManager.onKeycodePressed(keyCode)) return + if (ui.eventManager.onKeycodePressed(keyCode)) { + pressedKeys.add(keyCode) + return + } super.keyTyped(typedChar, keyCode) } -// no key released because 1.8.9 doesn't have it and I don't want to manually recreate it -// override fun keyReleased(keyCode: Int, scanCode: Int, modifiers: Int): Boolean { -// if (ui.eventManager?.onKeyReleased(keyCode) == true) { -// return true -// } -// return super.keyPressed(keyCode, scanCode, modifiers) -// } - override fun doesGuiPauseGame(): Boolean = false companion object { diff --git a/src/main/kotlin/me/odinmain/features/impl/skyblock/Ragaxe.kt b/src/main/kotlin/me/odinmain/features/impl/skyblock/Ragaxe.kt deleted file mode 100644 index 28535354c..000000000 --- a/src/main/kotlin/me/odinmain/features/impl/skyblock/Ragaxe.kt +++ /dev/null @@ -1,37 +0,0 @@ -package me.odinmain.features.impl.skyblock - -import me.odinmain.features.Category -import me.odinmain.features.Module -import me.odinmain.features.settings.Setting.Companion.withDependency -import me.odinmain.features.settings.impl.BooleanSetting -import me.odinmain.utils.skyblock.PlayerUtils -import me.odinmain.utils.skyblock.getSBStrength -import me.odinmain.utils.skyblock.heldItem -import me.odinmain.utils.skyblock.isHolding -import me.odinmain.utils.skyblock.modMessage -import me.odinmain.utils.skyblock.partyMessage -import net.minecraft.network.play.server.S29PacketSoundEffect - -object RagAxe : Module( - name = "Rag Axe", - description = "Tracks rag axe cooldowns." -) { - private val alert by BooleanSetting("Alert", true, description = "Alerts you when you start casting rag axe.") - private val alertCancelled by BooleanSetting("Alert Cancelled", true, description = "Alerts you when your rag axe is cancelled.") - private val strengthGainedMessage by BooleanSetting("Strength Gained", true, description = "Sends a mod message which will notify of strength gained from rag axe after casting") - private val announceStrengthGained by BooleanSetting("Send to party", false, description = "Sends party message of strength gained after casting").withDependency { strengthGainedMessage } - - init { - onMessage(Regex("Ragnarock was cancelled due to (?:being hit|taking damage)!")) { - if (alertCancelled) PlayerUtils.alert("§cRag Axe Cancelled") - } - - onPacket(S29PacketSoundEffect::class.java) { - if (it.soundName != "mob.wolf.howl" || it.pitch != 1.4920635f || !isHolding("RAGNAROCK_AXE")) return@onPacket - if (alert) PlayerUtils.alert("§aCasted Rag Axe") - val strengthGain = ((heldItem?.getSBStrength ?: return@onPacket) * 1.5).toInt() - if (strengthGainedMessage) modMessage("Gained strength: $strengthGain") - if (announceStrengthGained) partyMessage("Gained strength from rag axe: $strengthGain") - } - } -} \ No newline at end of file