Density function of average of max and min of uniform random variables

The mistake is in the integral to find density function of $Z$.

$ \displaystyle \theta - \frac{1}{2} < 2z - y < y < \theta + \frac{1}{2}$ would mean

For $\theta - \frac 12 \lt z \lt \theta, z \lt y \lt 2z + \frac 12 - \theta$

And for $\theta \lt z \lt \theta + \frac 12, z \lt y \lt \theta + \frac 12$

Integrating you get,

$ \displaystyle g(z) = n \cdot 2^{n-1} \cdot \left(\frac 12 + z - \theta\right)^{n-1} ~, \theta - \frac 12 \lt z \lt \theta$

$ \displaystyle g(z) = n \cdot 2^{n-1} \cdot \left(\frac 12 + \theta - z \right)^{n-1} ~, \theta \lt z \lt \theta + \frac 12$