Groves and water

Hi! I recently finished my Herobrine structures data package, but I always ran into problems that I couldn't resolve.

The main problem is that trees that are near water will spawn directly above the water, while the other half of the grove will simply spawn on the surface.

I need to do something to stop them from spawning underwater (I think there is a solution to make them stop spawning very close to water)

Hope you can help me with the code Thank you :)

Continue to help post