add options to the generation files

This commit is contained in:
Romain Beaumont 2015-10-09 14:17:13 +02:00
parent caf0ece703
commit e5a5973575
5 changed files with 45 additions and 33 deletions

View file

@ -5,5 +5,10 @@
"onlineMode": true, "onlineMode": true,
"logging": true, "logging": true,
"gameMode": 1, "gameMode": 1,
"generation":"diamond_square" "generation": {
"name":"diamond_square",
"options":{
"worldHeight":80
}
}
} }

View file

@ -5,5 +5,5 @@ module.exports=inject;
function inject(serv,settings) function inject(serv,settings)
{ {
serv.gameMode=settings.gameMode; serv.gameMode=settings.gameMode;
serv.spawnPoints=[new vec3(6,138,6),new vec3(3,138,6),new vec3(8,138,6)]; serv.spawnPoints=[new vec3(6,81,6),new vec3(3,81,6),new vec3(8,81,6)];
} }

View file

@ -10,5 +10,5 @@ var generations={
module.exports = inject; module.exports = inject;
function inject(serv,options) { function inject(serv,options) {
serv.world = new World(generations[options["generation"]]); serv.world = new World(generations[options["generation"].name](options["generation"].options));
} }

View file

@ -93,6 +93,8 @@ function DiamondSquare(size, roughness, seed) {
} }
} }
function generation(options) {
var worldHeight=options.worldHeight || 80;
// Selected empirically // Selected empirically
var size = 10000000; var size = 10000000;
var space = new DiamondSquare(size, size / 1000, Math.random() * 10000); var space = new DiamondSquare(size, size / 1000, Math.random() * 10000);
@ -105,7 +107,7 @@ function generateSimpleChunk(chunkX, chunkZ) {
for (var x = 0; x < 16; x++) { for (var x = 0; x < 16; x++) {
for (var z = 0; z < 16; z++) { for (var z = 0; z < 16; z++) {
var level = Math.floor(space.value(worldX + x, worldZ + z) * 138); var level = Math.floor(space.value(worldX + x, worldZ + z) * worldHeight);
for (var y = 0; y < 256; y++) { for (var y = 0; y < 256; y++) {
let block; let block;
@ -123,5 +125,7 @@ function generateSimpleChunk(chunkX, chunkZ) {
return chunk; return chunk;
} }
return generateSimpleChunk;
}
module.exports=generateSimpleChunk; module.exports=generation;

View file

@ -1,6 +1,7 @@
var Chunk = require('prismarine-chunk')(require("../version")); var Chunk = require('prismarine-chunk')(require("../version"));
var Vec3 = require('vec3'); var Vec3 = require('vec3');
function generation(options) {
function generateSimpleChunk(chunkX, chunkZ) { function generateSimpleChunk(chunkX, chunkZ) {
var chunk = new Chunk(); var chunk = new Chunk();
@ -15,5 +16,7 @@ function generateSimpleChunk(chunkX, chunkZ) {
return chunk; return chunk;
} }
return generateSimpleChunk;
}
module.exports=generateSimpleChunk; module.exports=generation;