public static float calcDistanceFromPlayerToPosition ( EntityPlayerSP player , Pos targetPos ) { double x = player . posX - targetPos . getX ( ) . doubleValue ( ) ; double y = player . posY - targetPos . getY ( ) . doubleValue ( ) ; double z = player . posZ - targetPos . getZ ( ) . doubleValue ( ) ; return ( float ) Math . sqrt ( x * x + y * y + z * z ) ; }
Calculate the Euclidean distance between the player and the target position .