After three in-game days or one real-world hour without sleeping in a bed, phantoms will begin to spawn in a Minecraft world. Until they are dealt with, they will attempt to attack the player from the skies whenever they have the opportunity.
There are a few ways to take phantoms out or keep them away, although killing them provides the most permanent solution. Regardless, there are a few tools at Minecraft players' disposal to deal with the winged attackers.
Minecraft: Killing or repelling phantoms
Since phantoms in Minecraft are aerial mobs, hitting them with arrows or striking them with melee weapons such as a sword or axe as they divebomb can be a great way to defeat them.
Hitting phantoms as they dive towards the player requires some timing, but it is completely doable with a bit of practice. Additionally, phantoms are similar to skeletons and zombies in that they burn alive in direct sunlight.
So although defeating phantoms in combat is useful, simply waiting or sleeping until morning can cook the hostile critters effectively. Sleeping not only forces the phantoms into direct sunlight, but will prevent the player who sleeps from spawning more phantoms. However, on multiplayer servers, phantoms can still spawn if other players have not slept as well.
For players who may be interested, phantoms are also somewhat afraid of feline mobs in Minecraft. In Minecraft: Java Edition, phantoms will attempt to stay at least 16 blocks away from cats, who hiss at their approach.
In Minecraft: Bedrock Edition, this also applies to Ocelots, providing players with more options. Although cats won't outright kill the phantoms flying about, they can at least keep them away while players tend to their business.
If all else fails, keeping the protection of cats or Ocelots until morning should prohibit phantoms from attacking the player until the sunlight takes care of them.
Sleep prevents phantoms from appearing, but if players do end up facing them, these options can allow them to stay safe and deal with the spooky mobs as they make their presence known.
Note: The article reflects the views of the writer.