I'm making macros for my Razer mouse, and a macro I want to have on my mouse is a frame-perfect sword spammer (i.e. when the attack animation ends, the mouse would automatically "left click" so I would have perfect timing for attacks), but I can't find the amount of time the attack animation takes in version 1.8 anywhere (I just find info about the attack cooldowns for 1.9). Does anyone know how long the animation takes to complete before you can attack again?
I believe it's shorter than the invincibility frame, which lasts 0.5 seconds. Any damage dealt to the target during the invincibility frame is simply ignored, but I dunno if this is also applied to non-damage effects like knockback (or flame, though the fire damage itself would be ignored). If you do not have other targets to move your mouse cursor to, you're literally wasting effort (durability, hunger, etc).
I have not tested but you can likely attack once per tick, 20 times per second, as that is how often the game checks for input, which is also the maximum rate at which in-game actions can occur since it runs at 20 TPS. If the game needs to register that you both pressed and released the button the time would be 2 ticks, or 10 times per second.
I do know that the attack animation is completely separate from the actual rate at which you can attack though; only in 1.9+ is it a direct indication of the duration of an attack and otherwise attacking faster will just reset it to the beginning of the animation.
Either way, if you really want to maximize DPS and avoid unnecessary attacks you want to be able to detect whether the target(s) is damage-immune, which would require a mod.