aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCalMWolfs <94038482+CalMWolfs@users.noreply.github.com>2023-07-29 18:54:59 +1000
committerGitHub <noreply@github.com>2023-07-29 10:54:59 +0200
commit9e9e603128925eb02f67710166e221094a2bbd94 (patch)
treec3bca478a46e7d733de382476e193595648f4c83
parent921ee1faa468d69fb70d2698fb210fc3eb61170d (diff)
downloadskyhanni-9e9e603128925eb02f67710166e221094a2bbd94.tar.gz
skyhanni-9e9e603128925eb02f67710166e221094a2bbd94.tar.bz2
skyhanni-9e9e603128925eb02f67710166e221094a2bbd94.zip
Code cleanup (#295)
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/ParkourWaypointSaver.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt9
2 files changed, 11 insertions, 2 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/test/ParkourWaypointSaver.kt b/src/main/java/at/hannibal2/skyhanni/test/ParkourWaypointSaver.kt
index 2fb009914..e2fc562f3 100644
--- a/src/main/java/at/hannibal2/skyhanni/test/ParkourWaypointSaver.kt
+++ b/src/main/java/at/hannibal2/skyhanni/test/ParkourWaypointSaver.kt
@@ -36,7 +36,7 @@ class ParkourWaypointSaver {
update()
}
if (config.saveKey == key) {
- val newLocation = LocationUtils.playerLocation().roundLocation()
+ val newLocation = LorenzVec.getBlockBelowPlayer()
if (locations.isNotEmpty()) {
if (newLocation == locations.last()) return
}
@@ -69,7 +69,7 @@ class ParkourWaypointSaver {
fun onRenderWorld(event: RenderWorldLastEvent) {
if (!LorenzUtils.inSkyBlock) return
- if (locations.size > 2) {
+ if (locations.size > 1) {
parkourHelper?.render(event)
} else {
for (location in locations) {
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt
index 46f273b2d..5f719da63 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt
@@ -96,6 +96,13 @@ data class LorenzVec(
fun round(decimals: Int) = LorenzVec(x.round(decimals), y.round(decimals), z.round(decimals))
+ fun roundLocationToBlock(): LorenzVec {
+ val x = (x - .499999).round(0)
+ val y = (y - .499999).round(0)
+ val z = (z - .499999).round(0)
+ return LorenzVec(x, y, z)
+ }
+
fun slope(other: LorenzVec, factor: Double) = add(other.subtract(this).scale(factor))
fun roundLocation(): LorenzVec {
@@ -127,6 +134,8 @@ data class LorenzVec(
val (x, y, z) = string.split(":").map { it.toDouble() }
return LorenzVec(x, y, z)
}
+
+ fun getBlockBelowPlayer() = LocationUtils.playerLocation().roundLocationToBlock().add(0.0, -1.0, 0.0)
}
}