Auto-Attack / Combat Macro (KillAura-style, inspired by Meteor Client)
Is your feature request related to a problem? Please describe.
There is currently no built-in high-level API in mineflayer for automated combat/targeting logic. Bot developers who want a bot to detect and attack nearby hostile entities (e.g. for defense against mobs, or for building PvE combat bots) must manually implement entity scanning, range checking, and attack-timing logic from scratch each time.
Describe the solution you'd like
Add a configurable bot.autoAttack (or bot.combatMacro) helper,
conceptually similar to Meteor Client's "KillAura" module, that:
- Scans nearby entities within a configurable range
- Filters by entity type/hostility (with a whitelist/blacklist option)
- Automatically faces and attacks the nearest/prioritized valid target
- Respects attack cooldown timing to mimic natural swing timing
- Emits events so bot developers can hook into target-acquired / target-lost / attack-performed for custom logic
Describe alternatives you've considered
Manually polling bot.entities, computing distances, and calling
bot.attack() on a custom interval - functional, but repetitive
boilerplate that many bot projects likely reimplement independently.
Additional context
️ Note: an automated "attack nearest entity" feature is functionally similar to what's commonly called a "KillAura" in PvP-cheat clients like Meteor Client. If implemented, this should be clearly scoped/documented as intended for PvE (mob defense), NPC/testing environments, or consensual PvP bot-vs-bot scenarios - and maintainers may reasonably want to consider whether to include safeguards or documentation discouraging use against real players on servers where automated combat assistance would violate server rules or constitute unfair play.
Source: PrismarineJS/mineflayer