Mineshafts for pre-1.13

This commit is contained in:
Cubitect 2021-07-08 22:49:07 +02:00
parent cb66b41328
commit 3b65b4bbf7
2 changed files with 18 additions and 6 deletions

View File

@ -225,7 +225,7 @@ int getStructurePos(int structureType, int mc, uint64_t seed, int regX, int regZ
case Mineshaft: case Mineshaft:
pos->x = (int)( ((uint32_t)regX << 4) ); pos->x = (int)( ((uint32_t)regX << 4) );
pos->z = (int)( ((uint32_t)regZ << 4) ); pos->z = (int)( ((uint32_t)regZ << 4) );
return isMineshaftChunk(seed, regX, regZ); return isMineshaftChunk(mc, seed, regX, regZ);
case Fortress: case Fortress:
if (mc < MC_1_16) { if (mc < MC_1_16) {
@ -261,15 +261,27 @@ int getStructurePos(int structureType, int mc, uint64_t seed, int regX, int regZ
return 0; return 0;
} }
int isMineshaftChunk(uint64_t seed, int chunkX, int chunkZ)
int isMineshaftChunk(int mc, uint64_t seed, int chunkX, int chunkZ)
{ {
uint64_t s; uint64_t s;
setSeed(&s, seed); setSeed(&s, seed);
uint64_t i = nextLong(&s); uint64_t i = nextLong(&s);
uint64_t j = nextLong(&s); uint64_t j = nextLong(&s);
s = chunkX * i ^ chunkZ * j ^ seed; setSeed(&s, chunkX * i ^ chunkZ * j ^ seed);
setSeed(&s, s); if (mc >= MC_1_13)
return nextDouble(&s) < 0.004; {
return nextDouble(&s) < 0.004;
}
else
{
int d = chunkX;
if (-chunkX > d) d = -chunkX;
if (+chunkZ > d) d = +chunkZ;
if (-chunkZ > d) d = -chunkZ;
skipNextN(&s, 1);
return nextDouble(&s) < 0.004 && nextInt(&s, 80) < d;
}
} }

View File

@ -327,7 +327,7 @@ Pos getLargeStructureChunkInRegion(StructureConfig config, uint64_t seed, int re
* The placement and biome check within a valid chunk is at block position (9,9) * The placement and biome check within a valid chunk is at block position (9,9)
* or at (2,2) with layer scale=4 from 1.16 onwards. * or at (2,2) with layer scale=4 from 1.16 onwards.
*/ */
int isMineshaftChunk(uint64_t seed, int chunkX, int chunkZ); int isMineshaftChunk(int mc, uint64_t seed, int chunkX, int chunkZ);
// not exacly a structure // not exacly a structure
static inline __attribute__((const)) static inline __attribute__((const))