From cb66b4132843e5b5191860f921de9973d2b68932 Mon Sep 17 00:00:00 2001 From: Cubitect Date: Thu, 8 Jul 2021 20:33:06 +0200 Subject: [PATCH] Made mineshafts usable with structure functions --- finders.c | 19 ++++++++++++++++++- finders.h | 2 ++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/finders.c b/finders.c index 5f4023b..ac6d6fa 100644 --- a/finders.c +++ b/finders.c @@ -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", diff --git a/finders.h b/finders.h index 8c848db..0620e39 100644 --- a/finders.h +++ b/finders.h @@ -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};