PrismarineJS/mineflayer-pvp

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

euseanwoon2016 posted onGitHub

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.


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.

posted by TheDudeFromCI about 4 years ago

Fund this Issue

$0.00
Funded

Pull requests