npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@nxg-org/mineflayer-custom-pvp

v1.7.6

Published

Intermediate functionality for bow and sword pvp.

Downloads

142

Readme

Mineflayer Advanced PvP

Enhanced combat capabilities for Mineflayer bots

License Minecraft Discord


Overview

This plugin enhances Mineflayer bots with advanced PvP capabilities through two specialized modules:

  • SwordPvP: Melee combat with intelligent criticals, strafing, and shield management
  • BowPvP: Ranged combat with improved projectile prediction and tactical awareness

Both modules extend existing plugins (mineflayer-pvp and minecrafthawkeye) with significant improvements and new features.


The SwordPvP module delivers accurate melee combat with features designed to match the effectiveness of modern PvP clients.

Key Features

  • MC-Accurate Hit Detection

    • Precise AABB collision models with eye-height projection
    • Matches Minecraft's actual hit detection mechanics
    • Improved hit registration compared to foot-position calculations
  • Advanced Critical Attacks

    • Achieves 80-100% critical hit rate depending on movement patterns
    • Multiple critical modes: hop, packet, and reactive timing
    • Packet-based criticals use optimized parameters based on popular clients
  • Intelligent Shield Handling

    • Automatic shield detection and countering
    • Weapon switching to axes when opponents shield
    • Both "legit" and "blatant" shielding modes
  • Tactical Movement

    • Multiple strafing patterns: circle, random, and intelligent
    • Sprint-tapping techniques for knockback manipulation
    • Automatic distance management
  • Enhanced Tracking

    • Precision target following with direct look commands
    • Multiple rotation modes: constant, silent, and instant
    • Option to predict target movement

Effectiveness

  • 80-95% critical hit rate during active combat
  • Near 100% critical success against stationary targets
  • Automatic tactical adaptation based on opponent behavior

The BowPvP module enhances ranged combat with improved targeting and tactical awareness features.

Key Features

  • Optimized Targeting

    • Body-centered aim for higher hit probability
    • Improved projectile physics models
  • Shot Prediction

    • Calculate trajectory between any two entities
    • Accurately predict endpoints of shots from any loaded entity
    • Determine hit probability for tactical decisions
  • Combat Awareness

    • Detection when the bot is being aimed at
    • Real-time threat assessment

Installation

npm install mineflayer-advanced-pvp

Basic Usage

const mineflayer = require('mineflayer')
const customPVP = require('mineflayer-advanced-pvp')
const { pathfinder, Movements } = require('mineflayer-pathfinder')

// Create your bot
const bot = mineflayer.createBot({
  host: 'localhost',
  username: 'CombatBot'
})

// Load plugins
bot.loadPlugin(customPVP)
bot.loadPlugin(pathfinder)

// Configure pathfinder movements
const moves = new Movements(bot)
moves.allowFreeMotion = true
moves.allowParkour = true
moves.allowSprinting = true
bot.pathfinder.setMovements(moves)

// The plugin adds bot.swordpvp and bot.bowpvp
bot.once('spawn', () => {
  // Configure combat options
  bot.swordpvp.options.cps = 20
  bot.swordpvp.options.critConfig.reaction.enabled = false
  bot.swordpvp.options.rotateConfig.smooth = true
  
  // Configure bow combat
  bot.bowpvp.useOffhand = false
  
  // Track attacks
  bot.swordpvp.on('attackedTarget', (target, reason, ticks) => {
    console.log(`Attack: ${reason}, next attack in ${ticks} ticks`)
  })
})

// Function to start fighting
const fight = () => {
  const target = bot.nearestEntity(e => e.type === 'player')
  if (target) {
    // Equip shield if available
    equipShield()
    // Start attacking
    bot.swordpvp.attack(target)
  }
}

// Helper to equip shield
async function equipShield() {
  if (bot.supportFeature('doesntHaveOffHandSlot')) return
  const shield = bot.util.inv.getAllItemsExceptCurrent('off-hand').find(e => e.name === 'shield')
  if (shield) {
    await bot.util.inv.customEquip(shield, 'off-hand')
  }
}

// Command handler
bot.on('chat', (username, message) => {
  switch (message) {
    case 'sword':
      bot.on('physicsTick', fight)
      break
    
    case 'stop':
      bot.removeListener('physicsTick', fight)
      bot.swordpvp.stop()
      break
      
    case 'packetmode':
      bot.swordpvp.options.critConfig.mode = 'packet'
      break
  }
})

Advanced Configuration

// Configure SwordPvP options
bot.once('spawn', () => {
  // Attack speed
  bot.swordpvp.options.cps = 20
  
  // Critical hit configuration
  bot.swordpvp.options.critConfig.enabled = true
  bot.swordpvp.options.critConfig.mode = 'packet'
  bot.swordpvp.options.critConfig.reaction.enabled = false
  
  // Follow configuration
  bot.swordpvp.options.followConfig.mode = 'jump'
  
  // Strafing configuration
  bot.swordpvp.options.strafeConfig.enabled = true
  bot.swordpvp.options.strafeConfig.mode.mode = 'intelligent'
  
  // Tap configuration for knockback
  bot.swordpvp.options.tapConfig.enabled = true
  bot.swordpvp.options.tapConfig.mode = 'wtap'
  
  // Look behavior
  bot.swordpvp.options.rotateConfig.smooth = true
  bot.swordpvp.options.rotateConfig.mode = 'constant'
})

For complete API documentation including all configuration options, methods, properties, and events, see the SwordPvP API Documentation.


Future Development

  • Expanded shield mechanics with proper movement penalties
  • Additional combat styles and strategies
  • Further optimization for server-specific combat mechanics

If you're interested in crystal PvP, check out mineflayer-auto-crystal.

Support

Need help? Join our Discord community for support, discussions, and updates.

Credits