aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils/BlockUtils.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/BlockUtils.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/BlockUtils.kt14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/BlockUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/BlockUtils.kt
index e16df26e9..a35d0de06 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/BlockUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/BlockUtils.kt
@@ -39,4 +39,18 @@ object BlockUtils {
return false
}
+
+ fun rayTrace(start: LorenzVec, direction: LorenzVec, distance: Double = 50.0): LorenzVec? {
+ val help = direction.normalize().multiply(distance)
+ val target = start.add(help)
+ val result = Minecraft.getMinecraft().theWorld.rayTraceBlocks(start.toVec3(), target.toVec3())
+
+ return result?.blockPos?.toLorenzVec()
+ }
+
+ fun getBlockLookingAt(duration: Double = 10.0) = rayTrace(
+ LocationUtils.playerEyeLocation(),
+ Minecraft.getMinecraft().thePlayer.lookVec.toLorenzVec(),
+ duration
+ )
} \ No newline at end of file