aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/test/ParkourWaypointSaver.kt
diff options
context:
space:
mode:
authorCalMWolfs <94038482+CalMWolfs@users.noreply.github.com>2023-10-12 22:31:49 +1100
committerGitHub <noreply@github.com>2023-10-12 13:31:49 +0200
commitdb0cd17c7019c072a5043ae8d0dca8ce6459fb32 (patch)
tree3e8a33b6d434d02d637e596eecd707d4e8c17495 /src/main/java/at/hannibal2/skyhanni/test/ParkourWaypointSaver.kt
parentd4084e697899f6dc3ceb87b4d229e0fe3819440a (diff)
downloadskyhanni-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/test/ParkourWaypointSaver.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/ParkourWaypointSaver.kt27
1 files changed, 10 insertions, 17 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/test/ParkourWaypointSaver.kt b/src/main/java/at/hannibal2/skyhanni/test/ParkourWaypointSaver.kt
index 59df2bf37..e74a6acff 100644
--- a/src/main/java/at/hannibal2/skyhanni/test/ParkourWaypointSaver.kt
+++ b/src/main/java/at/hannibal2/skyhanni/test/ParkourWaypointSaver.kt
@@ -1,7 +1,7 @@
package at.hannibal2.skyhanni.test
import at.hannibal2.skyhanni.SkyHanniMod
-import at.hannibal2.skyhanni.events.LorenzTickEvent
+import at.hannibal2.skyhanni.events.LorenzKeyPressEvent
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzVec
@@ -10,37 +10,30 @@ import at.hannibal2.skyhanni.utils.OSUtils
import at.hannibal2.skyhanni.utils.ParkourHelper
import at.hannibal2.skyhanni.utils.RenderUtils.drawFilledBoundingBox_nea
import at.hannibal2.skyhanni.utils.RenderUtils.expandBlock
+import at.hannibal2.skyhanni.utils.SimpleTimeMark
import net.minecraft.client.Minecraft
-import net.minecraft.client.gui.inventory.GuiChest
-import net.minecraft.client.gui.inventory.GuiEditSign
-import net.minecraft.client.gui.inventory.GuiInventory
import net.minecraftforge.client.event.RenderWorldLastEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
-import org.lwjgl.input.Keyboard
+import kotlin.time.Duration.Companion.milliseconds
class ParkourWaypointSaver {
private val config get() = SkyHanniMod.feature.dev.waypoint
- private var timeLastSaved: Long = 0
+ private var timeLastSaved = SimpleTimeMark.farPast()
private var locations = mutableListOf<LorenzVec>()
private var parkourHelper: ParkourHelper? = null
@SubscribeEvent
- fun onTick(event: LorenzTickEvent) {
+ fun onKeyClick(event: LorenzKeyPressEvent) {
if (!LorenzUtils.inSkyBlock) return
- if (!Keyboard.getEventKeyState()) return
+ if (Minecraft.getMinecraft().currentScreen != null) return
if (NEUItems.neuHasFocus()) return
- if (System.currentTimeMillis() - timeLastSaved < 250) return
+ if (timeLastSaved.passedSince() < 250.milliseconds) return
- Minecraft.getMinecraft().currentScreen?.let {
- if (it !is GuiInventory && it !is GuiChest && it !is GuiEditSign) return
- }
-
- val key = if (Keyboard.getEventKey() == 0) Keyboard.getEventCharacter().code + 256 else Keyboard.getEventKey()
- if (config.deleteKey == key) {
+ if (config.deleteKey == event.keyCode) {
locations = locations.dropLast(1).toMutableList()
update()
}
- if (config.saveKey == key) {
+ if (config.saveKey == event.keyCode) {
val newLocation = LorenzVec.getBlockBelowPlayer()
if (locations.isNotEmpty() && newLocation == locations.last()) return
locations.add(newLocation)
@@ -58,7 +51,7 @@ class ParkourWaypointSaver {
private fun MutableList<LorenzVec>.copyLocations() {
val resultList = mutableListOf<String>()
- timeLastSaved = System.currentTimeMillis()
+ timeLastSaved = SimpleTimeMark.now()
for (location in this) {
val x = location.x.toString().replace(",", ".")
val y = location.y.toString().replace(",", ".")