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 🙏

© 2024 – Pkg Stats / Ryan Hefner

minecrafthawkeye

v1.3.9

Published

Minecraft bot for equations when shooting an arrow

Downloads

1,552

Readme

minecraftHawkEye

Module for the Minecraft bot, hit 100% of the time with the bow, using the equations of parabolic shooting with friction

This module is based on bot of mineflayer repository

This calculate the trajectory of arrow / snowballs... to ensure which is the best angle to hit,

They can hit from 120 blocks away!

Install:

  • Install nodejs >= 14 from nodejs.org
  • npm i minecrafthawkeye

Usage:

First load mineflayer and minecrafthawkeye, and load plugin into mineflayer

const mineflayer = require('mineflayer')
const minecraftHawkEye = require('minecrafthawkeye');
bot.loadPlugin(minecraftHawkEye)
const weapon = 'bow'

Now you can request functions

// Get an a entity
// Example get te player entity, If emtpy return first player found
const playerEntity = bot.hawkEye.getPlayer(playername) 

// Auto attack every 1,2 secs to target
bot.hawkEye.autoAttack(target, weapon)

// Stop auto attack
bot.hawkEye.stop()

// Fire only 1 shot
bot.hawkEye.oneshot(target, weapon)

// Otherwise you can get Yaw and Pitch
bot.hawkEye.getMasterGrade(target, speedInVec3, weapon)
// With Yaw and Pitch you can use yourself bot.look(yaw,pitch) adn activate / deactivate main hand to fire


// Similar has oneshot but need yo add manually the Pitch and Way in radians
bot.hawkEye.simplyShot(yaw, pitch)

// If you want the result of calculation of arrow trajectory you can use that
bot.hawkEye.calculateArrowTrayectory(currentPosition, currentSpeed, pitch, yaw, 'bow')

// Start to check if any player / mob or any incoming to bot
// CAUTION: This use a lot of CPU, because on each tick game calculate all nearby mobs or players
bot.hawkEye.startRadar()
bot.hawkEye.stopRadar()

// Return a array of mobs & players are looking in your direction
bot.hawkEye.detectAim()

// Return list of arrows are in "air" just now
bot.hawkEye.detectProjectiles()

A example in one file:

// ** Grant OP to Archer **
// file: example.js
const mineflayer = require('mineflayer')
const minecraftHawkEye = require('minecrafthawkeye');
const Vec3 = require('Vec3')

const bot = mineflayer.createBot({
    host: process.argv[2] ? process.argv[2] : 'localhost',
    port: process.argv[3] ? parseInt(process.argv[3]) : 25565,
    username: process.argv[4] ? process.argv[4] : 'Archer',
    password: process.argv[5]
})

bot.loadPlugin(minecraftHawkEye)

bot.on('spawn', function() {
    bot.chat('/give ' + bot.username + ' bow{Enchantments:[{id:unbreaking,lvl:3}]} 1')
    bot.chat('/give ' + bot.username + ' minecraft:arrow 300')
    bot.chat('/time set day')
    bot.chat('/kill @e[type=minecraft:arrow]')
    bot.chat('Ready!')

    // Get target for block position, use whatever you need
    const target = bot.hawkEye.getPlayer()
    console.log(target)
    if (!target) {
        return false
    }

    weapon = 'bow'
    // Auto attack every 1,2 secs until target is dead or is to far away
    bot.hawkEye.autoAttack(target, weapon)
        // If you force stop attack use:
        // hawkEye.stop();

    // Use one shot time with calc:
    // bot.hawkEye.oneShot(target);

    // If you want to shot in XYZ position:
    /*
          const blockPosition = {
                  position: new Vec3(244.5, 75.5, -220),
                  isValid: true
              }
          // bot.hawkEye.oneShot(blockPosition);
          // bot.hawkEye.autoAttack(blockPosition);
      */
})

All is done, when is attack mode they get best possibility for impact, and shot arrow every 1,2 secs (max power)

Valid list of weapons or items that can calculate the perfect shot or launch it directly

bow
crossbow
snowball
ender_pearl
egg
splash_potion
trident

Events:

When but uses autoAttack and the mob is gone (killed o dissapeared)

bot.on('auto_shot_stopped', (target: Entity | OptionsMasterGrade) => {
    ///
})

When radar is active and some player or mob are aim you dispatch this event

bot.on('target_aiming_at_you', (entity: Entity, arrowTrajectory: Array<Vec3>) => {
    ///
})

When radar is active and When arrow are incoming and can be hit bot this event is dispatched

bot.on('incoming_projectil', (projectil: Projectil, arrowTrajectory: Array<Vec3>) => {
    ///
})

I'm glad I can help you, do we help each other?

Videos:

https://www.youtube.com/watch?v=InMkncDnYTA

https://www.youtube.com/watch?v=jjl4mMyL7hk

https://www.youtube.com/watch?v=OHX3u8Nrrp8

https://www.youtube.com/watch?v=VKg5xiww5Lo

TODOs

No TODOs! Anyone have more ideas? :D