Blackbody radiation can be viewed without any relation to a nearby body - as a photon gas in thermal equilibrium. The energy density of this radiation is then given by Planck's law.
Appendix
Let us consider a free photon gas in thermal equilibrium. If $n_{\mathbf{k},\nu}$ is the number of photons in mode characterized by wave number $\mathbf{k}$ and polarization $\nu$, then the energy contained in this mode is $\hbar\omega_{\mathbf{k},\nu}n_{\mathbf{k},\nu}$. The average energy contained in mode $\mathbf{k},\nu$ is thus
$$
\langle \hbar\omega_{\mathbf{k},\nu}n_{\mathbf{k},\nu}\rangle=
Z_{\mathbf{k},\nu}^{-1}\sum_{n_{\mathbf{k},\nu}=0}^\infty \hbar\omega_{\mathbf{k},\nu}n_{\mathbf{k},\nu}e^{-\beta \hbar\omega_{\mathbf{k},\nu}n_{\mathbf{k},\nu}},
$$
where
$$
Z_{\mathbf{k},\nu}=\sum_{n_{\mathbf{k},\nu}=0}^\infty e^{-\beta \hbar\omega_{\mathbf{k},\nu}n_{\mathbf{k},\nu}}=
\frac{1}{1-e^{-\beta \hbar\omega_{\mathbf{k},\nu}}}$$
and $\beta=1/(k_BT)$ is the inverse temperature.
We thus have
$$
\langle \hbar\omega_{\mathbf{k},\nu}n_{\mathbf{k},\nu}\rangle=
-\frac{\partial}{\partial \beta}\log Z_{\mathbf{k},\nu}=
\frac{\hbar\omega_{\mathbf{k},\nu}}{e^{\beta \hbar\omega_{\mathbf{k},\nu}}-1}
$$
The average total energy contained in the field is obtained by summing over all the field modes, that is
$$
\langle U\rangle =
\sum_{\mathbf{k},\nu}\langle \hbar\omega_{\mathbf{k},\nu}n_{\mathbf{k},\nu}\rangle=
\sum_{\mathbf{k},\nu}\frac{\hbar\omega_{\mathbf{k},\nu}}{e^{\beta \hbar\omega_{\mathbf{k},\nu}}-1} \tag{1}
$$
In summing over the modes I assumed periodic boundary conditions in a cube with side $L$, where the wave vectors are quantized as
$$
k_x=\frac{2\pi m_x}{L}, k_y=\frac{2\pi m_y}{L}, k_z=\frac{2\pi m_z}{L},\\
m_x, m_y, m_z=0, \pm 1, \pm 2,...
$$
Passage to integral over continuous spectrum is then performed by formally using that
$$
1=\Delta m_x \Delta m_y \Delta m_z =\left(\frac{L}{2\pi}\right)^3dk_x dk_ydk_z,
$$
that is the energy density is given by
$$
\langle u\rangle = \frac{\langle U\rangle}{L^3}=
\sum_{\nu}\int \frac{d^3\mathbf{k}}{(2\pi)^3}\frac{\hbar\omega_{\mathbf{k},\nu}}{e^{\beta \hbar\omega_{\mathbf{k},\nu}}-1}
$$
We next convert the integral over wave numbers to that over frequencies:
$$
\langle u\rangle =
\sum_{\nu}\int \frac{d^3\mathbf{k}}{(2\pi)^3}
\int_0^{+\infty}d\Omega\delta(\Omega - \omega_{\mathbf{k},\nu})
\frac{\hbar\omega_{\mathbf{k},\nu}} {e^{\beta \hbar\omega_{\mathbf{k},\nu}}-1}=
\int_0^{+\infty}d\Omega D(\Omega)
\frac{\hbar\Omega} {e^{\beta \hbar\Omega}-1},
$$
where the density-of-states is
$$
D(\Omega)=\sum_{\nu}\int \frac{d^3\mathbf{k}}{(2\pi)^3}\delta(\Omega - \omega_{\mathbf{k},\nu})
$$
Assuming now that mode frequency is given by $\omega_{\mathbf{k},\nu}=ck$ and is independent on the polarization, we obtain
$$
D(\Omega)=2\int \frac{d^3\mathbf{k}}{(2\pi)^3}\delta(\Omega - c k)=
\frac{2}{(2\pi)^3}4\pi\int_0^{+\infty}dk k^2\delta(\Omega - c k)=\frac{\Omega^2}{\pi^2 c^3}
$$
Thus, the energy density per unit volume is
$$
\langle u\rangle =
\int_0^{+\infty}d\Omega \frac{\hbar}{\pi^2 c^3}\frac{\Omega^3} {e^{\beta \hbar\Omega}-1}
\int_0^{+\infty}d\Omega \rho(\Omega),
$$
where
$$
\rho(\Omega)=\frac{\hbar}{\pi^2 c^3}\frac{\Omega^3} {e^{\beta \hbar\Omega}-1},
$$
is the energy density per unit volume per unit frequency, which differs from the Planck's formula for spectral radiance only by a constant coefficient.
Remark
In connection to question Why not use Bose Einstein Statistics to derive the Planck's blackbody radiation law?, note that Bose-Einstein statistics emerges naturally in this approach to BBR.