Minecraft wiki entry for Combat, associated text: If the player accidentally hits a dolphin, they will be attacked by multiple dolphins, and they can avoid them by swimming to the surface and get out of water. When the player see a dolphin on land trying to hurt the player, they can kill them safely as their movement is much slower on land, and since dolphins are aquatic mobs, they are affected by Impaling enchantment.‌[Java Edition only]