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

mineflayer-blockfinder

v0.0.7

Published

mineflayer plugin which gives bots a function to find the nearest block

Downloads

159

Readme

mineflayer-blockfinder

A library to help your mineflayer bot find blocks in the 3D world.

See mineflayer.

Usage

var mineflayer = require('mineflayer');
var blockFinderPlugin = require('mineflayer-blockfinder')(mineflayer);
var bot = mineflayer.createBot({username: 'Player'});

// Install the plugin
blockFinderPlugin(bot);

// Sample usage
bot.once('spawn', function() {
  bot.findBlock({
    point: bot.entity.position,
    matching: 56,
    maxDistance: 256,
    count: 1,
  }, function(err, blocks) {
    if (err) {
      return bot.chat('Error trying to find Diamond Ore: ' + err);
      bot.quit('quitting');
      return;
    }
    if (blocks.length) {
      bot.chat('I found a Diamond Ore block at ' + blocks[0].position + '.');
      bot.quit('quitting');
      return;
    } else {
      bot.chat("I couldn't find any Diamond Ore blocks within 256.");
      bot.quit('quitting');
      return;
    }
  });
});

Dependencies

Installation

npm install mineflayer-blockfinder

Or clone and cd into the directory

npm install .

Windows: You will need to install:

  • Python 2.5+ (but < 3.0): https://www.python.org/downloads/

  • Visual C++ 2015 build tools: http://landinghub.visualstudio.com/visual-cpp-build-tools

  • A version of Visual Studio: https://www.visualstudio.com/vs/community/

  • An older version of OpenSSL (bitness needs to match your installation of nodejs)

    ** 64-bit: http://slproweb.com/download/Win64OpenSSL-1_0_2k.exe

    ** 32-bit: http://slproweb.com/download/Win32OpenSSL-1_0_2k.exe

Documentation

bot.findBlock(options, callback)

Finds the nearest block(s) to the given point.

  • options - Additional options for the search:
    • point - The start position of the search.
    • matching - A function that returns true if the given block is a match. Also supports this value being a block id or array of block ids.
    • maxDistance - The furthest distance for the search, defaults to 64.
    • count - The number of blocks to find at most, defaults to 1.
  • callback - A callback function to get the result. Function signature:
function(err, arrayOfPoints)

bot.findBlockSync(options)

Finds the nearest block(s) to the given point synchronously.

  • options - See bot.findBlock.

History

0.0.7

  • DiamondFinder tested working, fix another issue related to recursion.

0.0.6

  • Fix recursion issue (thanks to rom1504)

0.0.5

  • Added new OctahedronIterator class, a fast finder algorithm that always returns the closest block, and is comparable with the cube algorithm.

0.0.4

  • Reverted algorithm to use the old, fast cube algorithm.

0.0.3

  • Fix 'matching' option to allow for array of ids instead of crashing.

0.0.2

  • Refactored algorithm to use an Iterator approach, to allow for re-useable code.
  • Rewrote block finding algorithm to guarantee the closest block is always found first.
  • Matching argument now takes an array of block ids, instead of block enums.