blob: 70ac2a3e9a17814bfc56138e41c3c77bafac8936 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
package at.hannibal2.skyhanni.utils
import net.minecraft.client.Minecraft
import net.minecraft.entity.Entity
import net.minecraft.util.AxisAlignedBB
object LocationUtils {
fun canSee(a: LorenzVec, b: LorenzVec): Boolean {
return Minecraft.getMinecraft().theWorld.rayTraceBlocks(a.toVec3(), b.toVec3(), false, true, false) == null
}
fun playerLocation() = Minecraft.getMinecraft().thePlayer.getLorenzVec()
fun LorenzVec.distanceToPlayer() = distance(playerLocation())
fun LorenzVec.distanceToPlayerSqIgnoreY() = distanceSqIgnoreY(playerLocation())
fun Entity.distanceToPlayer() = getLorenzVec().distance(playerLocation())
fun Entity.distanceTo(location: LorenzVec) = getLorenzVec().distance(location)
fun playerEyeLocation(): LorenzVec {
val player = Minecraft.getMinecraft().thePlayer
val vec = player.getLorenzVec()
return vec.add(0.0, 0.0 + player.getEyeHeight(), 0.0)
}
fun AxisAlignedBB.isVecInside(vec: LorenzVec) = isVecInside(vec.toVec3())
fun AxisAlignedBB.isPlayerInside() = isVecInside(playerLocation())
}
|