mirror of
https://github.com/Cubitect/cubiomes.git
synced 2025-09-22 19:24:35 -04:00
Replaced isZombieVillage with an updated getVillageType
This commit is contained in:
parent
263af396ba
commit
b2d122cf7f
169
finders.c
169
finders.c
@ -1357,9 +1357,7 @@ int isViableFeatureBiome(int mc, int structureType, int biomeID)
|
|||||||
if (mc < MC_1_14) return 0;
|
if (mc < MC_1_14) return 0;
|
||||||
// fall through
|
// fall through
|
||||||
case Village:
|
case Village:
|
||||||
if (biomeID == plains || biomeID == desert)
|
if (biomeID == plains || biomeID == desert || biomeID == savanna)
|
||||||
return 1;
|
|
||||||
if (mc >= MC_1_7 && biomeID == savanna)
|
|
||||||
return 1;
|
return 1;
|
||||||
if (mc >= MC_1_10 && biomeID == taiga)
|
if (mc >= MC_1_10 && biomeID == taiga)
|
||||||
return 1;
|
return 1;
|
||||||
@ -1530,7 +1528,7 @@ int isViableStructurePos(int structureType, int mc, LayerStack *g,
|
|||||||
{
|
{
|
||||||
int *map = NULL;
|
int *map = NULL;
|
||||||
Layer *l;
|
Layer *l;
|
||||||
int viable;
|
int viable = 0;
|
||||||
|
|
||||||
int64_t chunkX = blockX >> 4;
|
int64_t chunkX = blockX >> 4;
|
||||||
int64_t chunkZ = blockZ >> 4;
|
int64_t chunkZ = blockZ >> 4;
|
||||||
@ -1555,15 +1553,15 @@ int isViableStructurePos(int structureType, int mc, LayerStack *g,
|
|||||||
case Ocean_Ruin:
|
case Ocean_Ruin:
|
||||||
case Shipwreck:
|
case Shipwreck:
|
||||||
case Treasure:
|
case Treasure:
|
||||||
if (mc < MC_1_13) goto L_NOT_VIABLE;
|
if (mc < MC_1_13) goto L_not_viable;
|
||||||
goto L_FEATURE;
|
goto L_feature;
|
||||||
case Igloo:
|
case Igloo:
|
||||||
if (mc < MC_1_9) goto L_NOT_VIABLE;
|
if (mc < MC_1_9) goto L_not_viable;
|
||||||
goto L_FEATURE;
|
goto L_feature;
|
||||||
case Desert_Pyramid:
|
case Desert_Pyramid:
|
||||||
case Jungle_Pyramid:
|
case Jungle_Pyramid:
|
||||||
case Swamp_Hut:
|
case Swamp_Hut:
|
||||||
L_FEATURE:
|
L_feature:
|
||||||
if (mc < MC_1_16)
|
if (mc < MC_1_16)
|
||||||
{
|
{
|
||||||
l = &g->layers[L_VORONOI_ZOOM_1];
|
l = &g->layers[L_VORONOI_ZOOM_1];
|
||||||
@ -1580,10 +1578,10 @@ L_FEATURE:
|
|||||||
setWorldSeed(l, seed);
|
setWorldSeed(l, seed);
|
||||||
map = allocCache(l, 1, 1);
|
map = allocCache(l, 1, 1);
|
||||||
if (genArea(l, map, biomeX, biomeZ, 1, 1))
|
if (genArea(l, map, biomeX, biomeZ, 1, 1))
|
||||||
goto L_NOT_VIABLE;
|
goto L_not_viable;
|
||||||
if (!isViableFeatureBiome(mc, structureType, map[0]))
|
if (!isViableFeatureBiome(mc, structureType, map[0]))
|
||||||
goto L_NOT_VIABLE;
|
goto L_not_viable;
|
||||||
goto L_VIABLE;
|
goto L_viable;
|
||||||
|
|
||||||
case Village:
|
case Village:
|
||||||
l = &g->layers[L_RIVER_MIX_4];
|
l = &g->layers[L_RIVER_MIX_4];
|
||||||
@ -1592,15 +1590,16 @@ L_FEATURE:
|
|||||||
setWorldSeed(l, seed);
|
setWorldSeed(l, seed);
|
||||||
map = allocCache(l, 1, 1);
|
map = allocCache(l, 1, 1);
|
||||||
if (genArea(l, map, biomeX, biomeZ, 1, 1))
|
if (genArea(l, map, biomeX, biomeZ, 1, 1))
|
||||||
goto L_NOT_VIABLE;
|
goto L_not_viable;
|
||||||
if (!isViableFeatureBiome(mc, structureType, map[0]))
|
if (!isViableFeatureBiome(mc, structureType, map[0]))
|
||||||
goto L_NOT_VIABLE;
|
goto L_not_viable;
|
||||||
goto L_VIABLE;
|
viable = map[0]; // biome for viablility value as it may be useful for further analysis
|
||||||
|
goto L_viable;
|
||||||
|
|
||||||
case Outpost:
|
case Outpost:
|
||||||
{
|
{
|
||||||
if (mc < MC_1_14 || !testOutpostPos(seed, chunkX, chunkZ))
|
if (mc < MC_1_14 || !testOutpostPos(seed, chunkX, chunkZ))
|
||||||
goto L_NOT_VIABLE;
|
goto L_not_viable;
|
||||||
if (mc < MC_1_16)
|
if (mc < MC_1_16)
|
||||||
{
|
{
|
||||||
l = &g->layers[L_VORONOI_ZOOM_1];
|
l = &g->layers[L_VORONOI_ZOOM_1];
|
||||||
@ -1616,9 +1615,9 @@ L_FEATURE:
|
|||||||
setWorldSeed(l, seed);
|
setWorldSeed(l, seed);
|
||||||
map = allocCache(l, 1, 1);
|
map = allocCache(l, 1, 1);
|
||||||
if (genArea(l, map, biomeX, biomeZ, 1, 1))
|
if (genArea(l, map, biomeX, biomeZ, 1, 1))
|
||||||
goto L_NOT_VIABLE;
|
goto L_not_viable;
|
||||||
if (!isViableFeatureBiome(mc, structureType, map[0]))
|
if (!isViableFeatureBiome(mc, structureType, map[0]))
|
||||||
goto L_NOT_VIABLE;
|
goto L_not_viable;
|
||||||
// look for villages within 10 chunks
|
// look for villages within 10 chunks
|
||||||
int cx0 = (chunkX-10), cx1 = (chunkX+10);
|
int cx0 = (chunkX-10), cx1 = (chunkX+10);
|
||||||
int cz0 = (chunkZ-10), cz1 = (chunkZ+10);
|
int cz0 = (chunkZ-10), cz1 = (chunkZ+10);
|
||||||
@ -1632,26 +1631,26 @@ L_FEATURE:
|
|||||||
if (cx >= cx0 && cx <= cx1 && cz >= cz0 && cz <= cz1)
|
if (cx >= cx0 && cx <= cx1 && cz >= cz0 && cz <= cz1)
|
||||||
{
|
{
|
||||||
if (mc >= MC_1_16)
|
if (mc >= MC_1_16)
|
||||||
goto L_NOT_VIABLE;
|
goto L_not_viable;
|
||||||
if (isViableStructurePos(Village, mc, g, seed, p.x, p.z))
|
if (isViableStructurePos(Village, mc, g, seed, p.x, p.z))
|
||||||
goto L_NOT_VIABLE;
|
goto L_not_viable;
|
||||||
goto L_VIABLE;
|
goto L_viable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
goto L_VIABLE;
|
goto L_viable;
|
||||||
}
|
}
|
||||||
|
|
||||||
case Monument:
|
case Monument:
|
||||||
if (mc < MC_1_8)
|
if (mc < MC_1_8)
|
||||||
goto L_NOT_VIABLE;
|
goto L_not_viable;
|
||||||
else if (mc == MC_1_8)
|
else if (mc == MC_1_8)
|
||||||
{ // In 1.8 monuments require only a single deep ocean block.
|
{ // In 1.8 monuments require only a single deep ocean block.
|
||||||
l = g->entry_1;
|
l = g->entry_1;
|
||||||
setWorldSeed(l, seed);
|
setWorldSeed(l, seed);
|
||||||
map = allocCache(l, 1, 1);
|
map = allocCache(l, 1, 1);
|
||||||
if (genArea(l, map, (chunkX << 4) + 8, (chunkZ << 4) + 8, 1, 1))
|
if (genArea(l, map, (chunkX << 4) + 8, (chunkZ << 4) + 8, 1, 1))
|
||||||
goto L_NOT_VIABLE;
|
goto L_not_viable;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // Monuments require two viability checks with the ocean layer
|
{ // Monuments require two viability checks with the ocean layer
|
||||||
@ -1660,10 +1659,10 @@ L_FEATURE:
|
|||||||
setWorldSeed(l, seed);
|
setWorldSeed(l, seed);
|
||||||
map = allocCache(l, 1, 1);
|
map = allocCache(l, 1, 1);
|
||||||
if (genArea(l, map, chunkX, chunkZ, 1, 1))
|
if (genArea(l, map, chunkX, chunkZ, 1, 1))
|
||||||
goto L_NOT_VIABLE;
|
goto L_not_viable;
|
||||||
}
|
}
|
||||||
if (!isDeepOcean(map[0]))
|
if (!isDeepOcean(map[0]))
|
||||||
goto L_NOT_VIABLE;
|
goto L_not_viable;
|
||||||
if (mc >= MC_1_13)
|
if (mc >= MC_1_13)
|
||||||
l = &g->layers[L13_OCEAN_MIX_4];
|
l = &g->layers[L13_OCEAN_MIX_4];
|
||||||
else
|
else
|
||||||
@ -1673,38 +1672,36 @@ L_FEATURE:
|
|||||||
setWorldSeed(l, seed);
|
setWorldSeed(l, seed);
|
||||||
if (mc < MC_1_9 || areBiomesViable(l, NULL, biomeX, biomeZ, 16, getValidMonumentBiomes2()))
|
if (mc < MC_1_9 || areBiomesViable(l, NULL, biomeX, biomeZ, 16, getValidMonumentBiomes2()))
|
||||||
if (areBiomesViable(l, NULL, biomeX, biomeZ, 29, getValidMonumentBiomes1()))
|
if (areBiomesViable(l, NULL, biomeX, biomeZ, 29, getValidMonumentBiomes1()))
|
||||||
goto L_VIABLE;
|
goto L_viable;
|
||||||
goto L_NOT_VIABLE;
|
goto L_not_viable;
|
||||||
|
|
||||||
case Mansion:
|
case Mansion:
|
||||||
if (mc < MC_1_11)
|
if (mc < MC_1_11)
|
||||||
goto L_NOT_VIABLE;
|
goto L_not_viable;
|
||||||
l = &g->layers[L_RIVER_MIX_4];
|
l = &g->layers[L_RIVER_MIX_4];
|
||||||
biomeX = (chunkX << 4) + 8;
|
biomeX = (chunkX << 4) + 8;
|
||||||
biomeZ = (chunkZ << 4) + 8;
|
biomeZ = (chunkZ << 4) + 8;
|
||||||
setWorldSeed(l, seed);
|
setWorldSeed(l, seed);
|
||||||
if (areBiomesViable(l, NULL, biomeX, biomeZ, 32, getValidMansionBiomes()))
|
if (areBiomesViable(l, NULL, biomeX, biomeZ, 32, getValidMansionBiomes()))
|
||||||
goto L_VIABLE;
|
goto L_viable;
|
||||||
goto L_NOT_VIABLE;
|
goto L_not_viable;
|
||||||
|
|
||||||
case Ruined_Portal:
|
case Ruined_Portal:
|
||||||
if (mc >= MC_1_16)
|
if (mc >= MC_1_16)
|
||||||
goto L_VIABLE;
|
goto L_viable;
|
||||||
goto L_NOT_VIABLE;
|
goto L_not_viable;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"isViableStructurePos: validation for structure type %d not implemented",
|
"isViableStructurePos: validation for structure type %d not implemented",
|
||||||
structureType);
|
structureType);
|
||||||
goto L_NOT_VIABLE;
|
goto L_not_viable;
|
||||||
}
|
}
|
||||||
|
|
||||||
L_NOT_VIABLE:
|
L_viable:
|
||||||
viable = 0;
|
if (!viable)
|
||||||
if (0) {
|
|
||||||
L_VIABLE:
|
|
||||||
viable = 1;
|
viable = 1;
|
||||||
}
|
L_not_viable:
|
||||||
|
|
||||||
g->layers[L_BIOME_256] = lbiome;
|
g->layers[L_BIOME_256] = lbiome;
|
||||||
g->layers[L_SHORE_16] = lshore;
|
g->layers[L_SHORE_16] = lshore;
|
||||||
@ -1720,36 +1717,80 @@ L_VIABLE:
|
|||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
||||||
|
|
||||||
int isZombieVillage(const int mcversion, const int64_t worldSeed,
|
VillageType getVillageType(int mc, int64_t seed, int blockX, int blockZ, int biomeID)
|
||||||
const int regionX, const int regionZ)
|
|
||||||
{
|
{
|
||||||
Pos pos;
|
VillageType r = {};
|
||||||
int64_t seed = worldSeed;
|
if (!isViableFeatureBiome(mc, Village, biomeID))
|
||||||
|
return r;
|
||||||
|
|
||||||
if (mcversion < MC_1_10)
|
int64_t rnd = chunkGenerateRnd(seed, blockX >> 4, blockZ >> 4);
|
||||||
|
|
||||||
|
r.biome = biomeID;
|
||||||
|
|
||||||
|
if (mc >= MC_1_14)
|
||||||
{
|
{
|
||||||
printf("Warning: Zombie villages were only introduced in MC 1.10.\n");
|
skipNextN(&rnd, 1);
|
||||||
|
int t;
|
||||||
|
switch (biomeID)
|
||||||
|
{
|
||||||
|
case plains:
|
||||||
|
t = nextInt(&rnd, 204);
|
||||||
|
if (t < 50) { r.variant = 0; } // plains_fountain_01
|
||||||
|
else if (t < 100) { r.variant = 1; } // plains_meeting_point_1
|
||||||
|
else if (t < 150) { r.variant = 2; } // plains_meeting_point_2
|
||||||
|
else if (t < 200) { r.variant = 3; } // plains_meeting_point_3
|
||||||
|
else if (t < 201) { r.variant = 0; r.abandoned = 1; }
|
||||||
|
else if (t < 202) { r.variant = 1; r.abandoned = 1; }
|
||||||
|
else if (t < 203) { r.variant = 2; r.abandoned = 1; }
|
||||||
|
else if (t < 204) { r.variant = 3; r.abandoned = 1; }
|
||||||
|
break;
|
||||||
|
case desert:
|
||||||
|
t = nextInt(&rnd, 250);
|
||||||
|
if (t < 98) { r.variant = 1; } // desert_meeting_point_1
|
||||||
|
else if (t < 196) { r.variant = 2; } // desert_meeting_point_2
|
||||||
|
else if (t < 245) { r.variant = 3; } // desert_meeting_point_3
|
||||||
|
else if (t < 247) { r.variant = 1; r.abandoned = 1; }
|
||||||
|
else if (t < 249) { r.variant = 2; r.abandoned = 1; }
|
||||||
|
else if (t < 250) { r.variant = 3; r.abandoned = 1; }
|
||||||
|
break;
|
||||||
|
case savanna:
|
||||||
|
t = nextInt(&rnd, 459);
|
||||||
|
if (t < 100) { r.variant = 1; } // savanna_meeting_point_1
|
||||||
|
else if (t < 150) { r.variant = 2; } // savanna_meeting_point_2
|
||||||
|
else if (t < 300) { r.variant = 3; } // savanna_meeting_point_3
|
||||||
|
else if (t < 450) { r.variant = 4; } // savanna_meeting_point_4
|
||||||
|
else if (t < 452) { r.variant = 1; r.abandoned = 1; }
|
||||||
|
else if (t < 453) { r.variant = 2; r.abandoned = 1; }
|
||||||
|
else if (t < 456) { r.variant = 3; r.abandoned = 1; }
|
||||||
|
else if (t < 459) { r.variant = 4; r.abandoned = 1; }
|
||||||
|
break;
|
||||||
|
case taiga:
|
||||||
|
t = nextInt(&rnd, 100);
|
||||||
|
if (t < 49) { r.variant = 1; } // taiga_meeting_point_1
|
||||||
|
else if (t < 98) { r.variant = 2; } // taiga_meeting_point_2
|
||||||
|
else if (t < 99) { r.variant = 1; r.abandoned = 1; }
|
||||||
|
else if (t < 100) { r.variant = 2; r.abandoned = 1; }
|
||||||
|
break;
|
||||||
|
case snowy_tundra:
|
||||||
|
t = nextInt(&rnd, 306);
|
||||||
|
if (t < 100) { r.variant = 1; } // snowy_meeting_point_1
|
||||||
|
else if (t < 150) { r.variant = 2; } // snowy_meeting_point_2
|
||||||
|
else if (t < 300) { r.variant = 3; } // snowy_meeting_point_3
|
||||||
|
else if (t < 302) { r.variant = 1; r.abandoned = 1; }
|
||||||
|
else if (t < 303) { r.variant = 2; r.abandoned = 1; }
|
||||||
|
else if (t < 306) { r.variant = 3; r.abandoned = 1; }
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (mc >= MC_1_10)
|
||||||
|
{
|
||||||
|
skipNextN(&rnd, mc == MC_1_13 ? 10 : 11);
|
||||||
|
r.abandoned = nextInt(&rnd, 50) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the chunk position of the village
|
return r;
|
||||||
seed = regionX*341873128712 + regionZ*132897987541 + seed + VILLAGE_CONFIG.salt;
|
|
||||||
seed = (seed ^ 0x5deece66dLL);// & ((1LL << 48) - 1);
|
|
||||||
|
|
||||||
seed = (seed * 0x5deece66dLL + 0xbLL) & 0xffffffffffff;
|
|
||||||
pos.x = (seed >> 17) % VILLAGE_CONFIG.chunkRange;
|
|
||||||
|
|
||||||
seed = (seed * 0x5deece66dLL + 0xbLL) & 0xffffffffffff;
|
|
||||||
pos.z = (seed >> 17) % VILLAGE_CONFIG.chunkRange;
|
|
||||||
|
|
||||||
pos.x += regionX * VILLAGE_CONFIG.regionSize;
|
|
||||||
pos.z += regionZ * VILLAGE_CONFIG.regionSize;
|
|
||||||
|
|
||||||
// jump to the random number check that determines whether this is village
|
|
||||||
// is zombie infested
|
|
||||||
int64_t rnd = chunkGenerateRnd(worldSeed, pos.x , pos.z);
|
|
||||||
skipNextN(&rnd, mcversion == MC_1_13 ? 10 : 11);
|
|
||||||
|
|
||||||
return nextInt(&rnd, 50) == 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
18
finders.h
18
finders.h
@ -143,6 +143,15 @@ STRUCT(StrongholdIter)
|
|||||||
int mc; // minecraft version
|
int mc; // minecraft version
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
STRUCT(VillageType)
|
||||||
|
{
|
||||||
|
char abandoned; // is zombie village
|
||||||
|
char variant;
|
||||||
|
int biome;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/******************************** SEED FINDING *********************************
|
/******************************** SEED FINDING *********************************
|
||||||
*
|
*
|
||||||
* If we want to find rare seeds that meet multiple custom criteria then we
|
* If we want to find rare seeds that meet multiple custom criteria then we
|
||||||
@ -638,14 +647,11 @@ inline static int64_t chunkGenerateRnd(const int64_t worldSeed,
|
|||||||
return rnd;
|
return rnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Checks if the village in the given region would be infested by zombies.
|
VillageType getVillageType(int mc, int64_t seed, int blockX, int blockZ, int biomeID);
|
||||||
* (Minecraft 1.10+)
|
|
||||||
*/
|
|
||||||
int isZombieVillage(const int mcversion, const int64_t worldSeed,
|
|
||||||
const int regionX, const int regionZ);
|
|
||||||
|
|
||||||
|
|
||||||
/* Finds the number of each type of house that generate in a village.
|
/* Finds the number of each type of house that generate in a village
|
||||||
|
* (mc < MC_1_14)
|
||||||
* @worldSeed : world seed
|
* @worldSeed : world seed
|
||||||
* @chunkX, chunkZ : 16x16 chunk position of the village origin
|
* @chunkX, chunkZ : 16x16 chunk position of the village origin
|
||||||
* @housesOut : output number of houses for each entry in the house type
|
* @housesOut : output number of houses for each entry in the house type
|
||||||
|
Loading…
x
Reference in New Issue
Block a user