Prevent ghast spawn from Minecraft?

an
3

Hello we're building a zombie pigman farm and every time ghasts spawn and destroy everything. How can you prevent them from spawning?

lo

Command block to always active and repeat and then enter / kill @e [type = minecraft: ghast]

You can't do anything in survival.

an

Make a roof of slabs over the spawn areas.

And make sure that each spawn area is only 2 blocks high. Ghasts are namely 4 blocks high and can't spawn in 2 block high gaps.

an

So nonsense.

Have you noticed that ghasts have a bigger hitbox? As a result, they need more space to spawn. If they don't have this place they won't spawn. Simple. Using commands for this is exaggerated in a different way.