mirror of
https://github.com/danbulant/flying-squid
synced 2026-06-18 05:51:12 +00:00
add options to the generation files
This commit is contained in:
parent
caf0ece703
commit
e5a5973575
5 changed files with 45 additions and 33 deletions
|
|
@ -5,5 +5,10 @@
|
|||
"onlineMode": true,
|
||||
"logging": true,
|
||||
"gameMode": 1,
|
||||
"generation":"diamond_square"
|
||||
"generation": {
|
||||
"name":"diamond_square",
|
||||
"options":{
|
||||
"worldHeight":80
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,5 +5,5 @@ module.exports=inject;
|
|||
function inject(serv,settings)
|
||||
{
|
||||
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)];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,5 +10,5 @@ var generations={
|
|||
module.exports = inject;
|
||||
|
||||
function inject(serv,options) {
|
||||
serv.world = new World(generations[options["generation"]]);
|
||||
serv.world = new World(generations[options["generation"].name](options["generation"].options));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,35 +93,39 @@ function DiamondSquare(size, roughness, seed) {
|
|||
}
|
||||
}
|
||||
|
||||
function generation(options) {
|
||||
var worldHeight=options.worldHeight || 80;
|
||||
// Selected empirically
|
||||
var size = 10000000;
|
||||
var space = new DiamondSquare(size, size/1000, Math.random() * 10000);
|
||||
var size = 10000000;
|
||||
var space = new DiamondSquare(size, size / 1000, Math.random() * 10000);
|
||||
|
||||
function generateSimpleChunk(chunkX, chunkZ) {
|
||||
var chunk = new Chunk();
|
||||
function generateSimpleChunk(chunkX, chunkZ) {
|
||||
var chunk = new Chunk();
|
||||
|
||||
var worldX = chunkX * 16 + size/2;
|
||||
var worldZ = chunkZ * 16 + size/2;
|
||||
var worldX = chunkX * 16 + size / 2;
|
||||
var worldZ = chunkZ * 16 + size / 2;
|
||||
|
||||
for (var x = 0; x < 16;x++) {
|
||||
for (var z = 0; z < 16; z++) {
|
||||
var level = Math.floor(space.value(worldX + x, worldZ + z) * 138);
|
||||
for (var y = 0; y < 256; y++) {
|
||||
let block;
|
||||
for (var x = 0; x < 16; x++) {
|
||||
for (var z = 0; z < 16; z++) {
|
||||
var level = Math.floor(space.value(worldX + x, worldZ + z) * worldHeight);
|
||||
for (var y = 0; y < 256; y++) {
|
||||
let block;
|
||||
|
||||
if(y == 0) block = 7;
|
||||
else if(y < level) block = 3;
|
||||
else if (y == level) block = 2;
|
||||
else if (y < 20) block = 9;
|
||||
if (y == 0) block = 7;
|
||||
else if (y < level) block = 3;
|
||||
else if (y == level) block = 2;
|
||||
else if (y < 20) block = 9;
|
||||
|
||||
if(block) chunk.setBlockType(new Vec3(x, y, z), block);
|
||||
if (block) chunk.setBlockType(new Vec3(x, y, z), block);
|
||||
|
||||
chunk.setSkyLight(new Vec3(x, y, z), 15);
|
||||
chunk.setSkyLight(new Vec3(x, y, z), 15);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return chunk;
|
||||
return chunk;
|
||||
}
|
||||
return generateSimpleChunk;
|
||||
}
|
||||
|
||||
module.exports=generateSimpleChunk;
|
||||
module.exports=generation;
|
||||
|
|
|
|||
|
|
@ -1,19 +1,22 @@
|
|||
var Chunk = require('prismarine-chunk')(require("../version"));
|
||||
var Vec3 = require('vec3');
|
||||
|
||||
function generateSimpleChunk(chunkX, chunkZ) {
|
||||
var chunk=new Chunk();
|
||||
function generation(options) {
|
||||
function generateSimpleChunk(chunkX, chunkZ) {
|
||||
var chunk = new Chunk();
|
||||
|
||||
for (var x = 0; x < 16;x++) {
|
||||
for (var z = 0; z < 16; z++) {
|
||||
chunk.setBlockType(new Vec3(x, 50, z), 2);
|
||||
for (var y = 0; y < 256; y++) {
|
||||
chunk.setSkyLight(new Vec3(x, y, z), 15);
|
||||
for (var x = 0; x < 16; x++) {
|
||||
for (var z = 0; z < 16; z++) {
|
||||
chunk.setBlockType(new Vec3(x, 50, z), 2);
|
||||
for (var y = 0; y < 256; y++) {
|
||||
chunk.setSkyLight(new Vec3(x, y, z), 15);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return chunk;
|
||||
return chunk;
|
||||
}
|
||||
return generateSimpleChunk;
|
||||
}
|
||||
|
||||
module.exports=generateSimpleChunk;
|
||||
module.exports=generation;
|
||||
Loading…
Reference in a new issue