Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.evyatar.target;
- import org.bukkit.Location;
- import org.bukkit.entity.Player;
- public class TargetLocationCalculator
- {
- public static Location getRelativeLocation(Location from, double xzAngle, double yAngle, double distance)
- {
- xzAngle = Math.toRadians(xzAngle);
- yAngle = Math.toRadians(yAngle);
- double y = Math.sin(yAngle)*distance;
- double xzDistance = Math.cos(yAngle)*distance;
- double x = Math.cos(xzAngle)*xzDistance,
- z = Math.sin(xzAngle)*xzDistance;
- return from.clone().add(x, y, z);
- }
- public Location getTargetLocation(Player player, double distance)
- {
- Location playerLoc = player.getLocation();
- double xzAngle = playerLoc.getPitch() + 90D,
- yAngle = playerLoc.getYaw()*-1;
- return getRelativeLocation(playerLoc, xzAngle, yAngle, distance);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement