Web based viewer for servers and bots
Web based viewer for servers and bots
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, 1.21.1, 1.21.4. Other versions of the same major (e.g. 1.21.8) render with the textures and models of the closest supported one.
npm install prismarine-viewerconst 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:
The core rendering library. It provides Viewer and WorldView which together make it possible to render a minecraft world. Check its API
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: 6firstPerson is the view first person ? default: falseport the port for the webserver, default: 3000Players are rendered with their skin, wide or slim, and cape when the server sends skin data (online-mode servers).
Serve a webserver allowing to visualize a world.
const { standalone } = require('prismarine-viewer')Options:
version the version to use, default: 1.13.2generator a world generator function, default: (x, y, z) => 0center a vec3 to center the view on, default: new Vec3(0, 0, 0)viewDistance view radius, in chunks, default: 6port the port for the webserver, default: 3000Render the bot view and stream it to a file or over TCP.
const { headless } = require('prismarine-viewer')Options:
viewDistance view radius, in chunks, default: 6output the output file or a host:port address to stream to, default: output.mp4frames number of frames to record, -1 for infinite, default: 200width the width of a frame, default: 512height the height of a frame, default: 512All drawing function have a unique id that can be used to replace or erase the primitive.
Draw a line passing through all the points.
Remove the primitive with the given id from the display.
Stop the server and disconnect users.
npm run jestTest -- -t "1.9.4"
No open issues yet, or sync has not completed.