Made mineshafts usable with structure functions

This commit is contained in:
Cubitect 2021-07-08 20:33:06 +02:00
parent bfbd421ef5
commit cb66b41328
2 changed files with 20 additions and 1 deletions

View File

@ -146,6 +146,9 @@ int getStructureConfig(int structureType, int mc, StructureConfig *sconf)
case Treasure:
*sconf = TREASURE_CONFIG;
return mc >= MC_1_13;
case Mineshaft:
*sconf = MINESHAFT_CONFIG;
return 1;
case Fortress:
*sconf = mc <= MC_1_15 ? FORTRESS_CONFIG_115 : FORTRESS_CONFIG;
return 1;
@ -219,6 +222,11 @@ int getStructurePos(int structureType, int mc, uint64_t seed, int regX, int regZ
setSeed(&seed, seed);
return nextFloat(&seed) < 0.01;
case Mineshaft:
pos->x = (int)( ((uint32_t)regX << 4) );
pos->z = (int)( ((uint32_t)regZ << 4) );
return isMineshaftChunk(seed, regX, regZ);
case Fortress:
if (mc < MC_1_16) {
setAttemptSeed(&seed, regX << 4, regZ << 4);
@ -1451,6 +1459,9 @@ int isViableFeatureBiome(int mc, int structureType, int biomeID)
if (mc < MC_1_13) return 0;
return biomeID == beach || biomeID == snowy_beach;
case Mineshaft:
return isOverworld(mc, biomeID);
case Monument:
if (mc < MC_1_8) return 0;
return isDeepOcean(biomeID);
@ -1746,11 +1757,14 @@ L_feature:
int cx0 = (chunkX-10), cx1 = (chunkX+10);
int cz0 = (chunkZ-10), cz1 = (chunkZ+10);
int rx, rz;
StructureConfig vilconf;
if (!getStructureConfig(Village, mc, &vilconf))
goto L_not_viable;
for (rz = cz0 >> 5; rz <= cz1 >> 5; rz++)
{
for (rx = cx0 >> 5; rx <= cx1 >> 5; rx++)
{
Pos p = getFeaturePos(VILLAGE_CONFIG, seed, rx, rz);
Pos p = getFeaturePos(vilconf, seed, rx, rz);
int cx = p.x >> 4, cz = p.z >> 4;
if (cx >= cx0 && cx <= cx1 && cz >= cz0 && cz <= cz1)
{
@ -1816,6 +1830,9 @@ L_feature:
goto L_viable;
goto L_not_viable;
case Mineshaft:
goto L_viable;
default:
fprintf(stderr,
"isViableStructurePos: validation for structure type %d not implemented\n",

View File

@ -47,6 +47,7 @@ enum StructureType
Ruined_Portal,
Ruined_Portal_N,
Treasure,
Mineshaft,
Fortress,
Bastion,
End_City,
@ -97,6 +98,7 @@ _sc RUINED_PORTAL_CONFIG = { 34222645, 40, 25, Ruined_Portal, 0}; // overwo
_sc RUINED_PORTAL_N_CONFIG = { 34222645, 25, 15, Ruined_Portal_N, 0}; // nether
_sc TREASURE_CONFIG = { 10387320, 1, 1, Treasure, CHUNK_STRUCT};
_sc MINESHAFT_CONFIG = { 0, 1, 1, Mineshaft, CHUNK_STRUCT};
// nether and end structures
_sc FORTRESS_CONFIG_115 = { 0, 16, 8, Fortress, 0};