diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt | 20 |
1 files changed, 20 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 b9a790d31..ba82321f2 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt @@ -106,4 +106,24 @@ object LocationUtils { val maxZ = min(this.maxZ, other.maxZ) return AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ) } + + fun calculatePlayerYaw(): Float { + val player = Minecraft.getMinecraft().thePlayer + var yaw = player.rotationYaw % 360 + if (yaw < 0) yaw += 360 + if (yaw > 180) yaw -= 360 + + return yaw + } + + fun calculatePlayerFacingDirection(): LorenzVec { + var yaw = LocationUtils.calculatePlayerYaw() + 180 + return when { + yaw < 45 -> LorenzVec(0, 0, -1) + yaw < 135 -> LorenzVec(1, 0, 0) + yaw < 225 -> LorenzVec(0, 0, 1) + yaw < 315 -> LorenzVec(-1, 0, 0) + else -> LorenzVec(0, 0, -1) + } + } } |