Path: blob/master/examples/anvil_saver/saver.js
1468 views
/*1* This example demonstrates how to save a world with mineflayer and2* https://github.com/PrismarineJS/prismarine-provider-anvil3*/45const mineflayer = require('mineflayer')6const fs = require('fs')78if (process.argv.length < 4 || process.argv.length > 6) {9console.log('Usage : node saver.js <host> <port> [<name>] [<password>]')10process.exit(1)11}1213const bot = mineflayer.createBot({14host: process.argv[2],15port: parseInt(process.argv[3]),16username: process.argv[4] ? process.argv[4] : 'saver',17password: process.argv[5],18storageBuilder: ({ version, worldName }) => {19const Anvil = require('prismarine-provider-anvil').Anvil(version)20worldName = worldName.replace(/:/g, '_')21fs.mkdirSync(worldName)22return new Anvil(worldName)23}24})2526bot.on('spawn', () => {27bot.waitForChunksToLoad(() => {28console.log('World saved!')29})30})313233