In theory the spear should attack one time, so once the player attacked a mob the spear should go back to the original state.
However, in its current state every 10 ticks (or twice every second) the spear applies a damage to an entity (even if the entity is the same).
This means that if the player is far away enough (but he can still reach the entity) he will apply multiple times a damage to the same entity.
So to test this here is a simple method.
Summon an entity that takes no knockback (or that has the nbt
{NoAI:1}
applied)Get a few blocks away from the entity
slow down the game by running the command ”
/tick rate 1
”Now hold right click, aim for the mob and start running (that’s the best method to reach enough speed needed for the spear)
To my understanding this is intended behavior of the charge attack.