feat: oceanMonument

feat: Mesa biomes
feat: changed world generation according to java
fix: swamp hut changed to spruce
This commit is contained in:
Lord_Cambion
2026-04-07 19:41:14 +02:00
parent 17aff7edb3
commit 720e1a77a4
57 changed files with 3377 additions and 358 deletions
+136 -67
View File
@@ -3,89 +3,158 @@
#include "IntCache.h"
#include "RegionHillsLayer.h"
RegionHillsLayer::RegionHillsLayer(int64_t seed, shared_ptr<Layer> parent) : Layer(seed)
{
this->parent = parent;
this->riverNoise = nullptr;
}
RegionHillsLayer::RegionHillsLayer(int64_t seed, shared_ptr<Layer> parent, shared_ptr<Layer> riverNoise) : Layer(seed)
{
this->parent = parent;
this->riverNoise = riverNoise;
}
void RegionHillsLayer::init(int64_t seed)
{
Layer::init(seed);
if (riverNoise != nullptr)
riverNoise->init(seed);
}
bool RegionHillsLayer::biomesEqualOrMesaPlateau(int a, int b)
{
return a == b;
}
intArray RegionHillsLayer::getArea(int xo, int yo, int w, int h)
{
intArray b = parent->getArea(xo - 1, yo - 1, w + 2, h + 2);
intArray b = parent->getArea(xo - 1, yo - 1, w + 2, h + 2);
intArray noise = (riverNoise != nullptr)
? riverNoise->getArea(xo - 1, yo - 1, w + 2, h + 2)
: IntCache::allocate((w + 2) * (h + 2));
intArray result = IntCache::allocate(w * h);
for (int y = 0; y < h; y++)
for (int y = 0; y < h; ++y)
{
for (int x = 0; x < w; x++)
for (int x = 0; x < w; ++x)
{
initRandom(x + xo, y + yo);
int old = b[(x + 1) + (y + 1) * (w + 2)];
if (nextRandom(3) == 0)
{
int next = old;
if (old == Biome::desert->id)
{
next = Biome::desertHills->id;
}
else if (old == Biome::forest->id)
{
next = Biome::forestHills->id;
}
else if (old == Biome::taiga->id)
{
next = Biome::taigaHills->id;
}
else if (old == Biome::coldTaiga->id)
{
next = Biome::coldTaigaHills->id;
}
else if (old == Biome::megaTaiga->id)
{
next = Biome::megaTaigaHills->id;
}
else if (old == Biome::plains->id)
{
next = Biome::forest->id;
}
else if (old == Biome::iceFlats->id)
{
next = Biome::iceMountains->id;
}
else if (old == Biome::iceFlats->id)
{
next = Biome::iceSpikes->id;
}
else if (old == Biome::jungle->id)
{
next = Biome::jungleHills->id;
}
/*else if (old == Biome::savanna->id)
{
next = Biome::savannaPlateau->id;
}*/
if (next == old)
{
result[x + y * w] = old;
}
else
{
int _n = b[(x + 1) + (y + 1 - 1) * (w + 2)];
int _e = b[(x + 1 + 1) + (y + 1) * (w + 2)];
int _w = b[(x + 1 - 1) + (y + 1) * (w + 2)];
int _s = b[(x + 1) + (y + 1 + 1) * (w + 2)];
if (_n == old && _e == old && _w == old && _s == old)
{
result[x + y * w] = next;
}
else
{
result[x + y * w] = old;
}
}
int k = b [x + 1 + (y + 1) * (w + 2)];
int l = noise[x + 1 + (y + 1) * (w + 2)];
bool flag = (riverNoise != nullptr) && ((l - 2) % 29 == 0);
if (riverNoise != nullptr && k != 0 && l >= 2 && (l - 2) % 29 == 1 && k < 128)
{
result[x + y * w] = k;
}
else if (nextRandom(3) != 0 && !flag)
{
result[x + y * w] = k;
}
else
{
result[x + y * w] = old;
int i1 = k;
if (k == Biome::desert->id)
{
i1 = Biome::desertHills->id;
}
else if (k == Biome::forest->id)
{
i1 = Biome::forestHills->id;
}
else if (k == Biome::birchForest->id)
{
i1 = Biome::birchForestHills->id;
}
else if (k == Biome::roofedForest->id)
{
// Java: roofedForest -> plains
i1 = Biome::plains->id;
}
else if (k == Biome::taiga->id)
{
i1 = Biome::taigaHills->id;
}
else if (k == Biome::megaTaiga->id)
{
i1 = Biome::megaTaigaHills->id;
}
else if (k == Biome::coldTaiga->id)
{
i1 = Biome::coldTaigaHills->id;
}
else if (k == Biome::plains->id)
{
if (nextRandom(3) == 0)
i1 = Biome::forestHills->id;
else
i1 = Biome::forest->id;
}
else if (k == Biome::iceFlats->id)
{
i1 = Biome::iceMountains->id;
}
else if (k == Biome::jungle->id)
{
i1 = Biome::jungleHills->id;
}
else if (k == Biome::ocean->id)
{
// java: ocean → deepOcean
i1 = Biome::deepOcean->id;
}
else if (k == Biome::extremeHills->id)
{
i1 = Biome::smallerExtremeHills->id;
}
else if (k == Biome::savanna->id)
{
// Java: savanna → savannaPlateau
i1 = Biome::savannaPlateau->id;
}
else if (k == Biome::deepOcean->id && nextRandom(3) == 0)
{
i1 = (nextRandom(2) == 0) ? Biome::plains->id : Biome::forest->id;
}
if (i1 == k)
{
result[x + y * w] = k;
}
else
{
int _n = b[x + 1 + (y + 1 - 1) * (w + 2)];
int _e = b[x + 1 + 1 + (y + 1) * (w + 2)];
int _w = b[x + 1 - 1 + (y + 1) * (w + 2)];
int _s = b[x + 1 + (y + 1 + 1) * (w + 2)];
int neighbours = 0;
if (biomesEqualOrMesaPlateau(_n, k)) ++neighbours;
if (biomesEqualOrMesaPlateau(_e, k)) ++neighbours;
if (biomesEqualOrMesaPlateau(_w, k)) ++neighbours;
if (biomesEqualOrMesaPlateau(_s, k)) ++neighbours;
result[x + y * w] = (neighbours >= 3) ? i1 : k;
}
}
}
}