implement new terrain generator, cave generator, tree generator, implement big tree generator, improve light update performance

This commit is contained in:
LabyStudio
2022-05-04 23:35:53 +02:00
parent b52a1385b3
commit d846613ca9
21 changed files with 1380 additions and 196 deletions
@@ -22,12 +22,18 @@ export default class MetadataChunkBlock {
if (index > 32768) {
return;
}
for (let x = this.x1; x <= this.x2; x++) {
for (let z = this.z1; z <= this.z2; z++) {
if (!world.blockExists(x, 0, z)) {
continue;
}
let centerChunk = world.getChunkAt(x >> 4, z >> 4);
if (!centerChunk.loaded) {
return;
}
for (let y = this.y1; y <= this.y2; y++) {
if (y < 0 || y >= World.TOTAL_HEIGHT) {
continue;
+8 -3
View File
@@ -4,15 +4,14 @@ export default class Random {
constructor(seed = Date.now() % 1000000000 ^ Random.instances++ * 1000) {
this.mask = 0xffffffff;
this.m_w = (123456789 + seed) & this.mask;
this.m_z = (987654321 - seed) & this.mask;
this.setSeed(seed);
}
nextBoolean() {
return this.nextFloat() > 0.5;
}
nextInt(max) {
nextInt(max = 0x7fffffff) {
return Math.floor(this.nextFloat() * (max + 1));
}
@@ -24,4 +23,10 @@ export default class Random {
result /= 4294967296;
return result;
}
setSeed(seed) {
this.seed = seed;
this.m_w = (123456789 + seed) & this.mask;
this.m_z = (987654321 - seed) & this.mask;
}
}