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

prismarine-viewer

v1.28.0

Published

Web based viewer

Downloads

4,980

Readme

prismarine-viewer

Web based viewer for servers and bots

NPM version Build Status Discord Gitter Irc Issue Hunt

Try it on gitpod

Supports versions 1.8.8, 1.9.4, 1.10.2, 1.11.2, 1.12.2, 1.13.2, 1.14.4, 1.15.2, 1.16.1, 1.16.4, 1.17.1, 1.18.1, 1.19, 1.20.1.

Install

npm install prismarine-viewer

Example

const mineflayer = require('mineflayer')
const mineflayerViewer = require('prismarine-viewer').mineflayer

const bot = mineflayer.createBot({
  username: 'Bot'
})

bot.once('spawn', () => {
  mineflayerViewer(bot, { port: 3000 }) // Start the viewing server on port 3000

  // Draw the path followed by the bot
  const path = [bot.entity.position.clone()]
  bot.on('move', () => {
    if (path[path.length - 1].distanceTo(bot.entity.position) > 1) {
      path.push(bot.entity.position.clone())
      bot.viewer.drawLine('path', path)
    }
  })
})

More examples:

  • First person bot example
  • Record view as video file example
  • Streaming video to a python script example
  • Visualize a world, without a bot example
  • Visualize the world coming from a proxy example
  • Click to move example
  • Use the core api for viewing worlds example
  • Create an electron app with viewer example
  • Create a fully front end viewer with an in memory world example
  • A minecraft web client example, using mineflayer and a websocket proxy example
  • Export parts of worlds as screenshot or 3d models example

Projects using prismarine-viewer

API

prismarine-viewer

viewer

The core rendering library. It provides Viewer and WorldView which together make it possible to render a minecraft world. Check its API

mineflayer

Serve a webserver allowing to visualize the bot surrounding, in first or third person. Comes with drawing functionnalities.

const { mineflayer } = require('prismarine-viewer')

Options:

  • viewDistance view radius, in chunks, default: 6
  • firstPerson is the view first person ? default: false
  • port the port for the webserver, default: 3000

example

standalone

Serve a webserver allowing to visualize a world.

const { standalone } = require('prismarine-viewer')

Options:

  • version the version to use, default: 1.13.2
  • generator a world generator function, default: (x, y, z) => 0
  • center a vec3 to center the view on, default: new Vec3(0, 0, 0)
  • viewDistance view radius, in chunks, default: 6
  • port the port for the webserver, default: 3000

example

headless

Render the bot view and stream it to a file or over TCP.

const { headless } = require('prismarine-viewer')

Options:

  • viewDistance view radius, in chunks, default: 6
  • output the output file or a host:port address to stream to, default: output.mp4
  • frames number of frames to record, -1 for infinite, default: 200
  • width the width of a frame, default: 512
  • height the height of a frame, default: 512

example

Drawing (mineflayer mode)

All drawing function have a unique id that can be used to replace or erase the primitive.

bot.viewer.drawLine (id, points, color=0xff0000)

Draw a line passing through all the points.

bot.viewer.erase (id)

Remove the primitive with the given id from the display.

bot.viewer.close ()

Stop the server and disconnect users.

Tests

npm run jestTest -- -t "1.9.4"