More expressive dimensions

This commit is contained in:
Cubitect 2022-08-14 18:00:23 +02:00
parent 81adef19bf
commit a89d2cf9c9
4 changed files with 30 additions and 12 deletions

View File

@ -1854,7 +1854,7 @@ int isViableStructurePos(int structureType, Generator *g, int x, int z, uint32_t
int id;
if (g->dim == -1) // Nether
if (g->dim == DIM_NETHER)
{
if (structureType == Fortress && g->mc <= MC_1_17)
return 1;
@ -1893,7 +1893,7 @@ int isViableStructurePos(int structureType, Generator *g, int x, int z, uint32_t
id = getBiomeAt(g, 4, sampleX, sampleY, sampleZ);
return isViableFeatureBiome(g->mc, structureType, id);
}
else if (g->dim == +1) // End
else if (g->dim == DIM_END)
{
switch (structureType)
{
@ -2978,7 +2978,7 @@ int checkForBiomes(
return 0;
int i, j, k, ret;
if (g->mc <= MC_1_17 && dim == 0)
if (g->mc <= MC_1_17 && dim == DIM_OVERWORLD)
{
Layer *entry = (Layer*) getLayerForScale(g, r.scale);
ret = checkForBiomesAtLayer(&g->ls, entry, cache, seed,

View File

@ -62,7 +62,7 @@ int mapOceanMixMod(const Layer * l, int * out, int x, int z, int w, int h)
void setupGenerator(Generator *g, int mc, uint32_t flags)
{
g->mc = mc;
g->dim = 1000; // not initialized
g->dim = DIM_UNDEF;
g->flags = flags;
g->seed = 0;
g->sha = 0;
@ -98,24 +98,24 @@ void applySeed(Generator *g, int dim, uint64_t seed)
g->seed = seed;
g->sha = 0;
if (dim == 0)
if (dim == DIM_OVERWORLD)
{
if (g->mc <= MC_1_17)
setLayerSeed(g->entry ? g->entry : g->ls.entry_1, seed);
else
setBiomeSeed(&g->bn, seed, g->flags & LARGE_BIOMES);
}
else if (dim == -1 && g->mc >= MC_1_16)
else if (dim == DIM_NETHER && g->mc >= MC_1_16)
{
setNetherSeed(&g->nn, seed);
}
else if (dim == +1 && g->mc >= MC_1_9)
else if (dim == DIM_END && g->mc >= MC_1_9)
{
setEndSeed(&g->en, seed);
}
if (g->mc >= MC_1_15)
{
if (g->mc <= MC_1_17 && dim == 0 && !g->entry)
if (g->mc <= MC_1_17 && dim == DIM_OVERWORLD && !g->entry)
g->sha = g->ls.entry_1->startSalt;
else
g->sha = getVoronoiSHA(seed);
@ -129,7 +129,7 @@ size_t getMinCacheSize(const Generator *g, int scale, int sx, int sy, int sz)
sy = 1;
size_t len = (size_t)sx * sz * sy;
if (g->mc <= MC_1_17 && g->dim == 0)
if (g->mc <= MC_1_17 && g->dim == DIM_OVERWORLD)
{ // recursively check the layer stack for the max buffer
const Layer *entry = getLayerForScale(g, scale);
if (!entry) {
@ -161,7 +161,7 @@ int genBiomes(const Generator *g, int *cache, Range r)
int err = 1;
int i, k;
if (g->dim == 0)
if (g->dim == DIM_OVERWORLD)
{
if (g->mc <= MC_1_17)
{
@ -181,11 +181,11 @@ int genBiomes(const Generator *g, int *cache, Range r)
return genBiomeNoiseScaled(&g->bn, cache, r, g->mc, g->sha);
}
}
else if (g->dim == -1)
else if (g->dim == DIM_NETHER)
{
return genNetherScaled(&g->nn, cache, r, g->mc, g->sha);
}
else if (g->dim == +1)
else if (g->dim == DIM_END)
{
return genEndScaled(&g->en, cache, r, g->mc, g->sha);
}

View File

@ -158,6 +158,15 @@ int isOverworld(int mc, int id)
return 1;
}
int getDimension(int id)
{
if (id >= small_end_islands && id <= end_barrens) return DIM_END;
if (id >= soul_sand_valley && id <= basalt_deltas) return DIM_NETHER;
if (id == the_end) return DIM_END;
if (id == nether_wastes) return DIM_NETHER;
return DIM_OVERWORLD;
}
int getMutated(int mc, int id)
{
switch (id)

View File

@ -17,6 +17,14 @@ enum MCVersion
MC_1_19, MC_NEWEST = MC_1_19,
};
enum Dimension
{
DIM_NETHER = -1,
DIM_OVERWORLD = 0,
DIM_END = +1,
DIM_UNDEF = 1000,
};
enum BiomeID
{
none = -1,
@ -489,6 +497,7 @@ int genBiomeNoiseScaled(const BiomeNoise *bn, int *out, Range r, int mc, uint64_
int biomeExists(int mc, int id);
int isOverworld(int mc, int id);
int getDimension(int id);
int getMutated(int mc, int id);
int getCategory(int mc, int id);
int areSimilar(int mc, int id1, int id2);