How to use the prismarine-provider-anvil.level.readLevel function in prismarine-provider-anvil

To help you get started, we’ve selected a few prismarine-provider-anvil examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PrismarineJS / flying-squid / src / lib / plugins / world.js View on Github external
module.exports.server = async function (serv, { version, worldFolder, generation = { 'name': 'diamond_square', 'options': { 'worldHeight': 80 } } } = {}) {
  const World = require('prismarine-world')(version)

  const newSeed = generation.options.seed || Math.floor(Math.random() * Math.pow(2, 31))
  let seed
  let regionFolder
  if (worldFolder) {
    regionFolder = worldFolder + '/region'
    try {
      await fsStat(regionFolder)
    } catch (err) {
      await fsMkdir(regionFolder)
    }

    try {
      const levelData = await level.readLevel(worldFolder + '/level.dat')
      seed = levelData['RandomSeed'][0]
    } catch (err) {
      seed = newSeed
      await level.writeLevel(worldFolder + '/level.dat', { 'RandomSeed': [seed, 0] })
    }
  } else { seed = newSeed }
  generation.options.seed = seed
  generation.options.version = version
  serv.emit('seed', generation.options.seed)
  const generationModule = generations[generation.name] ? generations[generation.name] : require(generation.name)
  serv.overworld = new World(generationModule(generation.options), regionFolder)
  serv.netherworld = new World(generations['nether'](generation.options))
  // serv.endworld = new World(generations["end"]({}));

  // WILL BE REMOVED WHEN ACTUALLY IMPLEMENTED
  serv.overworld.blockEntityData = {}

prismarine-provider-anvil

Anvil Storage Provider implementation.

MIT
Latest version published 3 years ago

Package Health Score

49 / 100
Full package analysis