PrismarineJS / mineflayer-pvp

Adds support for basic PVP and PVE to Mineflayer bots.
MIT License
51 stars 19 forks source link

target.stop() at attack function causing unexpected behaviour. #27

Closed wooneusean closed 3 years ago

wooneusean commented 3 years ago

I suggest the removal of this line.

I have found that calling stop() here will make the bot receive a stoppedAttacking event even though they have just started attacking. At the end of the attack, stop() will be called again. This is, in my opinion, not really intuitive, since it will clash with the startedAttacking event especially if the callback is async.

After removing this line, I found that the events emitted makes more sense than how it is now.

I understand that this may be used to show that the bot has changed targets but putting it in one general event of stoppedAttacking is not intuitive.

TheDudeFromCI commented 3 years ago

That line was added to correctly stop the current attack if the bot was already in the middle of attacking another entity. Simply removing that line will prevent the stoppedAttacking from the first target to be called. I made a quick PR to fix this.