Skip to content

Commit

Permalink
Make created world loadable in singleplayer (#638)
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoy authored Dec 17, 2023
1 parent 2113acf commit 37bb939
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/lib/plugins/world.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const { level } = require('prismarine-provider-anvil')
const fsStat = promisify(fs.stat)
const fsMkdir = promisify(fs.mkdir)

module.exports.server = async function (serv, { version, worldFolder, generation = { name: 'diamond_square', options: { worldHeight: 80 } } } = {}) {
module.exports.server = async function (serv, options = {}) {
const { version, worldFolder, generation = { name: 'diamond_square', options: { worldHeight: 80 } } } = options
const World = require('prismarine-world')(version)
const mcData = require('minecraft-data')(version)
const Anvil = require('prismarine-provider-anvil').Anvil(version)
Expand All @@ -30,7 +31,11 @@ module.exports.server = async function (serv, { version, worldFolder, generation
seed = levelData.RandomSeed[0]
} catch (err) {
seed = newSeed
await level.writeLevel(worldFolder + '/level.dat', { RandomSeed: [seed, 0] })
await level.writeLevel(worldFolder + '/level.dat', {
RandomSeed: [seed, 0],
Version: { Name: options.version },
generatorName: generation.name === 'superflat' ? 'flat' : generation.name === 'diamond_square' ? 'default' : 'customized'
})
}
} else { seed = newSeed }
generation.options.seed = seed
Expand Down

0 comments on commit 37bb939

Please sign in to comment.