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-panorama

v0.0.1

Published

A Mineflayer Plugin for generating Panoramas

Downloads

5

Readme


Make Simple Panorama images and view them in your browser!

Download (1)

What is this?

This is a plugin for Mineflayer a high level Node.js API for creating Minecraft Bots. Mineflayer-panorama allows you to make pretty panorama images off the world the bot is in.

Getting Started

This plugin is built using Node and can be installed using:

git clone https://github.com/IceTank/mineflayer-panorama.git
cd mineflayer-panorama
npm install

Example

For use as a plugin to make Panorama Images:

const panorama = require('./index')
const mineflayer = require('mineflayer')
const fs = require('fs')
const bot = mineflayer.createBot({
  host: 'localhost'
})

bot.on('spawn', async () => {
  console.info('Bot spawned')
  bot.loadPlugin(panorama.image)
  bot.on('camera_ready', async () => {
    await bot.waitForChunksToLoad()
    console.info('Ready to use')
    let imageStream = await bot.panoramaImage.takePanoramaPictures()
    let image = fs.createWriteStream('panorama1.jpeg')
    imageStream.pipe(image)
    image.on('finish', () => {
      console.info('Wrote panorama image panorama1.jpeg')
    })
  })
})

This plugin also includes a webserver that can be used to view the generated images. The webserver opens a website on a given port and serves the current panorama view of the bot and a Panorama viewer. For an example see: example/browserCubeMap/index.js. Note: three.module.js has to be provided in public/js. If npm install did not download it, it has to be added manually.

Running on Windows

The rendering is done by node-canvas-webgl which is tricky to install on Windows. I recommend using a unix based operating system or Docker to run this plugin.

Documentation

async bot.panoramaImage.takePanoramaPictures(camPos)

Takes a panorama Image and resolves with a jpeg stream of that image on success.

  • camPos - a null, number or Vec3 like object
    • null - takes the panorama image from the bot current position
    • number - takes the panorama image with a high offset at the bots current location
    • Vec3 like - takes the panorama image at a given location. Note: the bot can only render chunks that are loaded. Taking images outside of the current render distance may result in a blank image off the current sky color.

async bot.panoramaImage.takePicture(lookAt, name)

Takes a picture of the current world at the bots current position looking at the point lookAt

  • lookAt - a Vec3 like object of the point the bot should look at
  • name - the name the jpeg image will be saved as

WebServer(bot, PORT)

A class providing a express app to host the panorama viewer on. When the page is opened the web server automatically calls bot.panoramaImage.takePanoramaImage to take an up to date panorama image to display in the panorama viewer.

  • bot - the mineflayer bot instance
  • PORT - the port the express app should listen on

WebServer.READY - boolean if the express app is ready

Events

"ready"

Emitted when the express app is ready and running

Docker

Example Dockerfiles are provided in the examples. To build an example Dockerfile use this command:

docker build . -f .\example\<the example>\Dockerfile -t <image name>

For running the container read the README.md files in the example folders.

TODO

  • Add panorama Video streaming/saving
  • Add entitys to the panorama view

License

This project uses the MIT license.

Contributions

This project is accepting PRs and Issues. See something you think can be improved? Go for it! Any and all help is highly appreciated!

For larger changes, it is recommended to discuss these changes in the issues tab before writing any code. It's also preferred to make many smaller PRs than one large one, where applicable.