feat: shore implementation

This commit is contained in:
Lord_Cambion 2026-05-16 15:06:17 +02:00
parent 2ed917481d
commit 50a65acac6
3 changed files with 87 additions and 72 deletions

View file

@ -13,30 +13,57 @@ intArray BiomeEdgeLayer::getArea(int xo, int yo, int w, int h)
intArray b = parent->getArea(xo - 1, yo - 1, w + 2, h + 2);
intArray result = IntCache::allocate(w * h);
int stride = w + 2;
for (int iy = 0; iy < h; ++iy)
{
for (int ix = 0; ix < w; ++ix)
{
initRandom(ix + xo, iy + yo);
int center = b[(ix + 1) + (iy + 1) * stride];
int n = b[(ix + 1) + (iy + 0) * stride];
int e = b[(ix + 2) + (iy + 1) * stride];
int w1 = b[(ix + 0) + (iy + 1) * stride];
int s = b[(ix + 1) + (iy + 2) * stride];
if (!checkEdge(b, result, ix, iy, stride, Biome::extremeHills->id, Biome::smallerExtremeHills->id, center) &&
!checkEdge(b, result, ix, iy, stride, Biome::mesaPlateauF->id, Biome::mesaPlateau->id, center) &&
!checkEdge(b, result, ix, iy, stride, Biome::mesaPlateau->id, Biome::mesaPlateau->id, center) &&
!checkEdge(b, result, ix, iy, stride, Biome::megaTaiga->id, Biome::megaTaiga->id, center))
if (center == Biome::extremeHills->id)
{
if (center == Biome::desert->id) {
int n = b[(ix + 1) + (iy + 0) * stride];
int e = b[(ix + 2) + (iy + 1) * stride];
int w1 = b[(ix + 0) + (iy + 1) * stride];
int s = b[(ix + 1) + (iy + 2) * stride];
if (n == Biome::iceFlats->id || e == Biome::iceFlats->id || w1 == Biome::iceFlats->id || s == Biome::iceFlats->id) {
center = Biome::extremeHills->id;
}
}
result[ix + iy * w] = center;
if (n != center || e != center || w1 != center || s != center)
{ result[ix + iy * w] = Biome::smallerExtremeHills->id; continue; }
}
else if (center == Biome::mesaPlateauF->id)
{
if (n != center || e != center || w1 != center || s != center)
{ result[ix + iy * w] = Biome::mesaPlateau->id; continue; }
}
else if (center == Biome::mesaPlateau->id)
{
if (n != center || e != center || w1 != center || s != center)
{ result[ix + iy * w] = Biome::mesaPlateau->id; continue; }
}
else if (center == Biome::megaTaiga->id)
{
if (n != center || e != center || w1 != center || s != center)
{ result[ix + iy * w] = Biome::taiga->id; continue; }
}
else if (center == Biome::desert->id)
{
if (n == Biome::iceFlats->id || e == Biome::iceFlats->id ||
w1 == Biome::iceFlats->id || s == Biome::iceFlats->id)
{ result[ix + iy * w] = Biome::smallerExtremeHills->id; continue; }
}
else if (center == Biome::swampland->id)
{
int desertId = Biome::desert->id;
int coldTaigaId = Biome::coldTaiga->id;
int iceFlatsId = Biome::iceFlats->id;
if (n==desertId||e==desertId||w1==desertId||s==desertId ||
n==coldTaigaId||e==coldTaigaId||w1==coldTaigaId||s==coldTaigaId ||
n==iceFlatsId||e==iceFlatsId||w1==iceFlatsId||s==iceFlatsId)
{ result[ix + iy * w] = Biome::plains->id; continue; }
int jungleId = Biome::jungle->id;
if (n==jungleId||e==jungleId||w1==jungleId||s==jungleId)
{ result[ix + iy * w] = Biome::jungleEdge->id; continue; }
}
result[ix + iy * w] = center;
}
}
return result;

View file

@ -89,8 +89,8 @@ LayerArray Layer::getDefaultLayers(int64_t seed, LevelType* levelType, void* sup
shared_ptr<Layer> mixed = make_shared<RiverMixerLayer>(seed32, biomeLayer, riverLayerFinal, 0x64);
shared_ptr<Layer> voronoi = make_shared<VoronoiZoom>(seed32, mixed, 0xA);
mixed->init(seed);
voronoi->init(seed);
mixed->init((uint32_t)seed);
voronoi->init((uint32_t)seed);
LayerArray result(3, false);
result[0] = mixed;

View file

@ -1,4 +1,4 @@
#include "stdafx.h"
#include "stdafx.h"
#include "net.minecraft.world.level.newbiome.layer.h"
#include "net.minecraft.world.level.biome.h"
@ -10,72 +10,60 @@ ShoreLayer::ShoreLayer(int64_t seed, shared_ptr<Layer> parent, int64_t seedMixup
intArray ShoreLayer::getArea(int xo, int yo, int w, int h)
{
intArray b = parent->getArea(xo - 1, yo - 1, w + 2, h + 2);
intArray result = IntCache::allocate(w * h);
for (int y = 0; y < h; y++)
{
{
for (int x = 0; x < w; x++)
{
{
initRandom(x + xo, y + yo);
int old = b[(x + 1) + (y + 1) * (w + 2)];
int _n = b[(x + 1) + (y + 0) * (w + 2)];
int _e = b[(x + 2) + (y + 1) * (w + 2)];
int _w = b[(x + 0) + (y + 1) * (w + 2)];
int _s = b[(x + 1) + (y + 2) * (w + 2)];
if (old == Biome::mushroomIsland->id)
{
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 == Biome::ocean->id || _e == Biome::ocean->id || _w == Biome::ocean->id || _s == Biome::ocean->id || _n == Biome::deepOcean->id || _e == Biome::deepOcean->id || _w == Biome::deepOcean->id || _s == Biome::deepOcean->id)
{
{
if (_n == Biome::ocean->id || _e == Biome::ocean->id ||
_w == Biome::ocean->id || _s == Biome::ocean->id ||
_n == Biome::deepOcean->id || _e == Biome::deepOcean->id ||
_w == Biome::deepOcean->id || _s == Biome::deepOcean->id)
result[x + y * w] = Biome::mushroomIslandShore->id;
}
else
{
else
result[x + y * w] = old;
}
else if (old != Biome::ocean->id && old != Biome::deepOcean->id &&
old != Biome::river->id && old != Biome::swampland->id &&
old != Biome::extremeHills->id)
{
if (_n == Biome::ocean->id || _e == Biome::ocean->id ||
_w == Biome::ocean->id || _s == Biome::ocean->id ||
_n == Biome::deepOcean->id || _e == Biome::deepOcean->id ||
_w == Biome::deepOcean->id || _s == Biome::deepOcean->id)
{
if (old == Biome::taiga->id || old == Biome::taigaHills->id ||
old == Biome::megaTaiga->id || old == Biome::megaTaigaHills->id ||
old == Biome::coldTaiga->id || old == Biome::coldTaigaHills->id)
result[x + y * w] = Biome::coldBeach->id;
else
result[x + y * w] = Biome::beaches->id;
}
}
else if (old != Biome::ocean->id && old != Biome::deepOcean->id && old != Biome::river->id && old != Biome::swampland->id && old != Biome::extremeHills->id)
{
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 == Biome::ocean->id || _e == Biome::ocean->id || _w == Biome::ocean->id || _s == Biome::ocean->id || _n == Biome::deepOcean->id || _e == Biome::deepOcean->id || _w == Biome::deepOcean->id || _s == Biome::deepOcean->id)
{
if (old == Biome::taiga->id || old == Biome::taigaHills->id || old == Biome::megaTaiga->id || old == Biome::megaTaigaHills->id || old == Biome::coldTaiga->id || old == Biome::coldTaigaHills->id)
{
result[x + y * w] = Biome::coldBeach->id;
}
else
{
result[x + y * w] = Biome::beaches->id;
}
}
else
{
result[x + y * w] = old;
}
}
else if (old == Biome::extremeHills->id)
{
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 != Biome::extremeHills->id || _e != Biome::extremeHills->id || _w != Biome::extremeHills->id || _s != Biome::extremeHills->id)
{
result[x + y * w] = Biome::smallerExtremeHills->id;
}
else
{
result[x + y * w] = old;
}
}
else
{
else
result[x + y * w] = old;
}
else if (old == Biome::extremeHills->id)
{
if (_n != Biome::extremeHills->id || _e != Biome::extremeHills->id ||
_w != Biome::extremeHills->id || _s != Biome::extremeHills->id)
result[x + y * w] = Biome::smallerExtremeHills->id;
else
result[x + y * w] = old;
}
else
{
result[x + y * w] = old;
}
}
}
return result;
}