Turrets seek hostile mobs with their beam and slowly impart damage to them.
Creating a turret requires a beacon (Wither heads), obsidian, and an End Crystal (ghast tears).
Place a beacon, then obsidian above, and then the End Crystal on top. You can remove the obsidian block afterwards or replace it with a different block, but removing the block is recommended so that it does not block line of sight.