superb-warfare/src/main/java/com/atsuishio/superbwarfare/tools/VectorTool.java
2025-01-26 10:17:39 +08:00

16 lines
512 B
Java

package com.atsuishio.superbwarfare.tools;
import net.minecraft.util.Mth;
import net.minecraft.world.phys.Vec3;
public class VectorTool {
public static double calculateAngle(Vec3 start, Vec3 end) {
double startLength = start.length();
double endLength = end.length();
if (startLength > 0.0D && endLength > 0.0D) {
return Math.toDegrees(Math.acos(Mth.clamp(start.dot(end) / (startLength * endLength), -1, 1)));
} else {
return 0.0D;
}
}
}