mirror of https://github.com/kami-blue/client
[fix] Don't run InventoryMove when searching in ClickGUI/HudEditor
This commit is contained in:
parent
226db7af93
commit
486f276526
|
@ -1,14 +1,16 @@
|
||||||
package me.zeroeightsix.kami.module.modules.movement
|
package me.zeroeightsix.kami.module.modules.movement
|
||||||
|
|
||||||
import me.zeroeightsix.kami.KamiMod
|
import me.zeroeightsix.kami.KamiMod
|
||||||
|
import me.zeroeightsix.kami.gui.AbstractKamiGui
|
||||||
import me.zeroeightsix.kami.module.Module
|
import me.zeroeightsix.kami.module.Module
|
||||||
import me.zeroeightsix.kami.setting.ModuleConfig.setting
|
import me.zeroeightsix.kami.setting.ModuleConfig.setting
|
||||||
|
import me.zeroeightsix.kami.util.threads.safeListener
|
||||||
import net.minecraft.client.gui.GuiChat
|
import net.minecraft.client.gui.GuiChat
|
||||||
import net.minecraft.client.gui.GuiRepair
|
import net.minecraft.client.gui.GuiRepair
|
||||||
|
import net.minecraft.client.gui.GuiScreen
|
||||||
import net.minecraft.client.gui.inventory.GuiEditSign
|
import net.minecraft.client.gui.inventory.GuiEditSign
|
||||||
import net.minecraft.util.MovementInputFromOptions
|
import net.minecraft.util.MovementInputFromOptions
|
||||||
import net.minecraftforge.client.event.InputUpdateEvent
|
import net.minecraftforge.client.event.InputUpdateEvent
|
||||||
import org.kamiblue.event.listener.listener
|
|
||||||
import org.lwjgl.input.Keyboard
|
import org.lwjgl.input.Keyboard
|
||||||
|
|
||||||
object InventoryMove : Module(
|
object InventoryMove : Module(
|
||||||
|
@ -22,22 +24,22 @@ object InventoryMove : Module(
|
||||||
private var hasSent = false
|
private var hasSent = false
|
||||||
|
|
||||||
init {
|
init {
|
||||||
listener<InputUpdateEvent> {
|
safeListener<InputUpdateEvent> {
|
||||||
if (it.movementInput !is MovementInputFromOptions || checkGui()) return@listener
|
if (it.movementInput !is MovementInputFromOptions || isInvalidGui(mc.currentScreen)) return@safeListener
|
||||||
|
|
||||||
if (Keyboard.isKeyDown(Keyboard.KEY_LEFT)) {
|
if (Keyboard.isKeyDown(Keyboard.KEY_LEFT)) {
|
||||||
mc.player.rotationYaw = mc.player.rotationYaw - rotateSpeed
|
player.rotationYaw = player.rotationYaw - rotateSpeed
|
||||||
}
|
}
|
||||||
if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) {
|
if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) {
|
||||||
mc.player.rotationYaw = mc.player.rotationYaw + rotateSpeed
|
player.rotationYaw = player.rotationYaw + rotateSpeed
|
||||||
}
|
}
|
||||||
|
|
||||||
// pitch can not exceed 90 degrees nor -90 degrees, otherwise AAC servers will flag this and kick you.
|
// pitch can not exceed 90 degrees nor -90 degrees, otherwise AAC servers will flag this and kick you.
|
||||||
if (Keyboard.isKeyDown(Keyboard.KEY_UP)) {
|
if (Keyboard.isKeyDown(Keyboard.KEY_UP)) {
|
||||||
mc.player.rotationPitch = (mc.player.rotationPitch - rotateSpeed).coerceAtLeast(-90.0f)
|
player.rotationPitch = (player.rotationPitch - rotateSpeed).coerceAtLeast(-90.0f)
|
||||||
}
|
}
|
||||||
if (Keyboard.isKeyDown(Keyboard.KEY_DOWN)) {
|
if (Keyboard.isKeyDown(Keyboard.KEY_DOWN)) {
|
||||||
mc.player.rotationPitch = (mc.player.rotationPitch + rotateSpeed).coerceAtMost(90.0f)
|
player.rotationPitch = (player.rotationPitch + rotateSpeed).coerceAtMost(90.0f)
|
||||||
}
|
}
|
||||||
|
|
||||||
it.movementInput.moveStrafe = 0.0f
|
it.movementInput.moveStrafe = 0.0f
|
||||||
|
@ -81,16 +83,16 @@ object InventoryMove : Module(
|
||||||
}
|
}
|
||||||
} catch (e: IndexOutOfBoundsException) {
|
} catch (e: IndexOutOfBoundsException) {
|
||||||
if (!hasSent) {
|
if (!hasSent) {
|
||||||
KamiMod.LOG.error("$chatName Error: Key is bound to a mouse button!")
|
KamiMod.LOG.error("$chatName Error: Key is bound to a mouse button!", e)
|
||||||
e.printStackTrace()
|
|
||||||
hasSent = true
|
hasSent = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkGui() = mc.currentScreen == null
|
private fun isInvalidGui(guiScreen: GuiScreen?) = guiScreen == null
|
||||||
|| mc.currentScreen is GuiChat
|
|| guiScreen is GuiChat
|
||||||
|| mc.currentScreen is GuiEditSign
|
|| guiScreen is GuiEditSign
|
||||||
|| mc.currentScreen is GuiRepair
|
|| guiScreen is GuiRepair
|
||||||
|
|| guiScreen.let { it is AbstractKamiGui<*, *> && it.searching }
|
||||||
}
|
}
|
Loading…
Reference in New Issue