diff --git a/common/src/main/kotlin/net/spaceeye/someperipherals/stuff/raycasting/RaycastFunctions.kt b/common/src/main/kotlin/net/spaceeye/someperipherals/stuff/raycasting/RaycastFunctions.kt index 0e1dab8..34d4f12 100644 --- a/common/src/main/kotlin/net/spaceeye/someperipherals/stuff/raycasting/RaycastFunctions.kt +++ b/common/src/main/kotlin/net/spaceeye/someperipherals/stuff/raycasting/RaycastFunctions.kt @@ -1,5 +1,6 @@ package net.spaceeye.someperipherals.stuff.raycasting +import org.joml.Quaternionf import net.minecraft.core.BlockPos import net.minecraft.core.Direction import net.minecraft.server.level.ServerLevel @@ -16,7 +17,6 @@ import net.spaceeye.someperipherals.SomePeripherals import net.spaceeye.someperipherals.SomePeripheralsConfig import net.spaceeye.someperipherals.stuff.BallisticFunctions.rad import net.spaceeye.someperipherals.stuff.utils.* -import org.joml.Quaternionf import org.valkyrienskies.mod.common.getShipManagingPos import java.lang.Math.* @@ -243,7 +243,7 @@ object RaycastFunctions { //No idea how or why it works, don't use it anywhere else other than eulerRotationCalc private fun quatToUnit(rot: Quaternionf): Vector3d { val quint = Quaternionf(0f, 1f, 0f, 0f) - val rota = Quaternionf(-rot.x(), -rot.y(), -rot.z(), rot.w()) + val rota = Quaternionf(rot).conjugate() rot.mul(quint); rot.mul(rota) return Vector3d( -rot.x().toDouble(), @@ -258,7 +258,7 @@ object RaycastFunctions { val yaw = (if (yaw_ < 0) { max(yaw_, -PI/2) } else { min(yaw_ , PI/2) }) //idk why roll is yaw, and it needs to be inverted so that +yaw is right and -yaw is left - val rotation = Quaternionf().rotateXYZ(-yaw.toFloat(), pitch.toFloat(), 0f) + val rotation = Quaternionf().rotationXYZ(-yaw.toFloat(), pitch.toFloat(), 0f) direction.mul(rotation) return quatToUnit(direction) } @@ -346,8 +346,8 @@ object RaycastFunctions { Direction.EAST -> Vector3d(0, 1, 0) null -> throw AssertionError("Direction is null, how.") } - val vec = dir_enum.step().normalize() - val dir = Vector3d(vec.x(), vec.y(), vec.z()) + val tmp = dir_enum.step() + val dir = Vector3d(tmp.x, tmp.y, tmp.z).snormalize() vectorRotationCalc(Pair(dir, dir.cross(up).scross(dir)), var1, var2, var3) }