PrismarineJS / mineflayer

Create Minecraft bots with a powerful, stable, and high level JavaScript API.
https://prismarinejs.github.io/mineflayer/
MIT License
4.96k stars 904 forks source link

Optimize digging #923

Closed wvffle closed 4 years ago

wvffle commented 4 years ago

Is your feature request related to a problem?

There are a limited number of event listeners so using one listener per block whilst digging is not optimal

Describe the solution you'd like

https://github.com/PrismarineJS/mineflayer/blob/master/lib/plugins/digging.js#L51-L64 this should be one global handler and checked against some location cache object

Additional context

https://github.com/PrismarineJS/mineflayer/blob/master/lib/plugins/digging.js#L29

rom1504 commented 4 years ago

What problem do you want to solve by changing this behavior ?

On Mon, Mar 23, 2020, 08:21 Kasper Seweryn notifications@github.com wrote:

Is your feature request related to a problem?

There are a limited number of event listeners so using one listener per block whilst digging is not optimal Describe the solution you'd like

https://github.com/PrismarineJS/mineflayer/blob/master/lib/plugins/digging.js#L51-L64 this should be one global handler and checked against some location cache object Additional context

https://github.com/PrismarineJS/mineflayer/blob/master/lib/plugins/digging.js#L29

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/PrismarineJS/mineflayer/issues/923, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAR437WRRUXQL6EUENOKR3TRI4EXRANCNFSM4LRUY7TA .

wvffle commented 4 years ago

Sometimes it can exceed the limit of 11 max listeners. Also applying a lot of listeners may be slower than using one and checking against a cache object. This should be at least benchmarked.

rom1504 commented 4 years ago

Can't see why. Read the implementation of event listener, I think you'll understand better what it's doing

On Tue, Mar 24, 2020, 12:54 Kasper Seweryn notifications@github.com wrote:

Sometimes it can exceed the limit of 11 max listeners. Also applying a lot of listeners may be slower than using one and checking against a cache object. This should be at least benchmarked.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/PrismarineJS/mineflayer/issues/923#issuecomment-603195520, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAR437UVR7BGBQSBRIWKJ2LRJCNNRANCNFSM4LRUY7TA .

Karang commented 4 years ago

Is it still an issue? I can't see why either. Anyway, digging is kind of slow process due to the game mechanics (one block at a time) so I'm not sure why this would need to be optimized.

rom1504 commented 4 years ago

yeah, not an issue