aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt
diff options
context:
space:
mode:
authorILike2WatchMemes <ilike2watchmemes@gmail.com>2024-03-10 20:48:46 +0100
committerGitHub <noreply@github.com>2024-03-10 20:48:46 +0100
commit504924b65b0b1cf6bc5deaf2a46e2162504d63bf (patch)
tree621119b07ab8c79d01f21d90f619074819fe0fb7 /src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt
parent6b19f73c526fc4bbb196b7b547750ebe60feb76d (diff)
downloadskyhanni-504924b65b0b1cf6bc5deaf2a46e2162504d63bf.tar.gz
skyhanni-504924b65b0b1cf6bc5deaf2a46e2162504d63bf.tar.bz2
skyhanni-504924b65b0b1cf6bc5deaf2a46e2162504d63bf.zip
Feature: Lane Switching Notification (#1075)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt
index 29cc1d569..24b84dd7f 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt
@@ -1,5 +1,6 @@
package at.hannibal2.skyhanni.utils
+import at.hannibal2.skyhanni.utils.LorenzUtils.round
import net.minecraft.client.Minecraft
import net.minecraft.entity.Entity
import net.minecraft.util.AxisAlignedBB
@@ -11,6 +12,13 @@ object LocationUtils {
fun playerLocation() = Minecraft.getMinecraft().thePlayer.getLorenzVec()
+ fun distanceFromPreviousTick(): Double = with(Minecraft.getMinecraft().thePlayer) {
+ val oldPos = LorenzVec(prevPosX, prevPosY, prevPosZ)
+ val newPos = LorenzVec(posX, posY, posZ)
+
+ (oldPos.distance(newPos) * 20).round(2)
+ }
+
fun LorenzVec.distanceToPlayer() = distance(playerLocation())
fun LorenzVec.distanceToPlayerIgnoreY() = distanceIgnoreY(playerLocation())