# @nxg-org/mineflayer-custom-pvp

> Intermediate functionality for bow and sword pvp.

Latest version **1.7.16** (published 2026-04-16) · GPL-3.0 license · 0 weekly downloads

## Install

```sh
npm install @nxg-org/mineflayer-custom-pvp
pnpm add @nxg-org/mineflayer-custom-pvp
yarn add @nxg-org/mineflayer-custom-pvp
bun add @nxg-org/mineflayer-custom-pvp
```

## Health

**Score 50/100 (C)** — status: stable.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 1.7.16 |
| Published | 2026-04-16 |
| First published | 2021-12-06 |
| Weekly downloads | 0 |
| License | GPL-3.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 160.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 18 |
| Author | generel_schwerz |
| Maintainers | generel_schwerz, rob9315 |
| Keywords | mineflayer, mineflayer-pvp, mineflayer-plugin, mineflayer-custom-pvp |

## Links

- npm: https://www.npmjs.com/package/@nxg-org/mineflayer-custom-pvp
- Repository: https://github.com/nxg-org/mineflayer-custom-pvp
- Homepage: https://github.com/nxg-org/mineflayer-custom-pvp#readme
- Issues: https://github.com/nxg-org/mineflayer-custom-pvp/issues
- npm.io page: https://npm.io/package/@nxg-org/mineflayer-custom-pvp

## Dependencies (5)

- [mineflayer-pathfinder](https://npm.io/package/mineflayer-pathfinder.md) ^2.4.5
- [@nxg-org/mineflayer-tracker](https://npm.io/package/@nxg-org/mineflayer-tracker.md) ^1.1.1
- [@nxg-org/mineflayer-smooth-look](https://npm.io/package/@nxg-org/mineflayer-smooth-look.md) ^1.0.3
- [@nxg-org/mineflayer-util-plugin](https://npm.io/package/@nxg-org/mineflayer-util-plugin.md) ^1.8.4
- [@nxg-org/mineflayer-trajectories](https://npm.io/package/@nxg-org/mineflayer-trajectories.md) ^1.2.0

## Recent versions

- 1.7.16 (latest) — 2026-04-16
- 1.7.15 — 2026-04-16
- 1.7.14 — 2026-04-16
- 1.7.13 — 2026-04-16
- 1.7.12 — 2026-04-16
- 1.7.11 — 2026-04-16
- 1.7.10 — 2026-04-16
- 1.7.9 — 2026-04-03
- 1.7.8 — 2026-04-03
- 1.7.7 — 2026-04-03
- 1.7.6 — 2025-03-07
- 1.7.5 — 2025-03-06
- 1.7.4 — 2025-03-06
- 1.6.14 — 2025-03-03
- 1.6.13 — 2025-03-03
- … 47 more at https://npm.io/package/@nxg-org/mineflayer-custom-pvp/versions

## README

<div align="center">

# Mineflayer Advanced PvP

*Enhanced combat capabilities for Mineflayer bots*

[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://opensource.org/licenses/MIT)
[![Minecraft](https://img.shields.io/badge/MC-1.8--1.19-brightgreen.svg)](https://www.minecraft.net/)
[![Discord](https://img.shields.io/badge/chat-on%20discord-7289da.svg)](https://discord.gg/ytKSJPbUX6)

</div>

---

## 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.

---

<h2 align="center">🗡️ SwordPvP Module</h2>

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

---

<h2 align="center">🏹 BowPvP Module</h2>

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

```bash
npm install mineflayer-advanced-pvp
```

## Basic Usage

```javascript
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

```javascript
// 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](src/swordpvp/API.md).

---

## 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](https://github.com/nxg-org/mineflayer-auto-crystal).

## Support

Need help? Join our [Discord community](https://discord.gg/ytKSJPbUX6) for support, discussions, and updates.

## Credits

- Based on [mineflayer-pvp](https://github.com/PrismarineJS/mineflayer-pvp) and [minecrafthawkeye](https://github.com/sefirosweb/minecraftHawkEye)
- Critical attack system inspired by modern PvP clients

---
_Source: https://npm.io/package/@nxg-org/mineflayer-custom-pvp · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
