-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeneration.c
79 lines (63 loc) · 2.06 KB
/
generation.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include "generation.h"
void initGeneration() {
initBiomes();
}
void getStrongholds(int64_t *seed, Pos *strongholds, LayerStack *g) {
double d = nextDouble(seed) * PI * 2.0;
int perRingCount = 0, m = 0, perRing = STRONGHOLD_SPREAD;
int* validStrongholdBiomes = getValidStrongholdBiomes();
for (int n = 0; n < STRONGHOLD_COUNT; n++)
{
double e = (4 * STRONGHOLD_DISTANCE + STRONGHOLD_DISTANCE * m * 6) + (nextDouble(seed) - 0.5) * STRONGHOLD_DISTANCE * 2.5;
Pos chunk = {
round(cos(d) * e),
round(sin(d) * e)
};
Pos blockPos = findBiomePosition(MC_1_16, *g, NULL, (chunk.x << 4) + 8, (chunk.z << 4) + 8, 112, validStrongholdBiomes, seed, NULL);
if (blockPos.x != (chunk.x << 4) + 8 && blockPos.z != (chunk.z << 4) + 8)
{
chunk.x = blockPos.x >> 4;
chunk.z = blockPos.z >> 4;
}
strongholds[n] = chunk;
d += PI * 2 / (double) perRing;
perRingCount++;
if (perRingCount == perRing)
{
m++;
perRingCount = 0;
perRing += 2 * perRing / (m + 1);
perRing = (perRing >= STRONGHOLD_COUNT - n) ? STRONGHOLD_COUNT - n : perRing;
d += nextDouble(seed) * PI * 2.0;
}
}
}
/*
But 0 does mean Desert_Pyramid
What is this good for?
int configToStructureName(StructureConfig config)
{
switch (config.seed)
{
case 165745296: return Outpost;
case 14357617: return Desert_Pyramid;
default: return 0;
}
}
*/
/*
already supplied by cubiomes:
Pos getStructureChunkInRegion(const StructureConfig config, int64_t seed, const int regionX, const int regionZ);
Pos getPyramidPos(int64_t seed, int x, int z)
{
int regionX = x;
int regionZ = z;
int64_t regionSeed = regionX * 341873128712 + regionZ * 132897987541 + seed + 14357617; //165745296;
setSeed(®ionSeed);
Pos pos = {
regionX * 32 + nextInt(®ionSeed, 24),
regionZ * 32 + nextInt(®ionSeed, 24)
};
return pos;
}
*/