1) Are you using Optifine or any other client modifications?
2) What resource packs are you using?
3) What version of Minecraft is this happening in?
From my experience, this sounds like a bug in preview_OptiFine_1.16.1_HD_U_G2_pre4, which caused some mobs to only exist server-side, and not client-side (therefore swords don't work, but projectiles do). Other coremods could cause this issue too.
I highly doubt it'll be the resource pack, but I wouldn't put it past some internet no-life to create a resource pack which effects more than just the renderer.
If you're running Minecraft completely vanilla, then try to record the glitch and make separate bug reports here:
https://www.cubecraft.net/link-forums/java-bug-reports.76/
and here:
https://minecraft.net/en-us/bugs/pc/