Cubitect / cubiomes

C library that mimics the Minecraft biome generation.
MIT License
556 stars 98 forks source link

Stronghold position output isn't correct for MC 1.12 #92

Closed xxMattewxx closed 1 year ago

xxMattewxx commented 1 year ago

Not sure about other MC versions, but Mushroom Island Shore isn't considered a valid stronghold biome in MC 1.12. Code below outputs start stronghold chunk as (60, 87), with the correct being (59, 89):

#include "./cubiomes-master/finders.h"
#include <sstream>

int main(int argc, char** argv) {
    Generator g;
        setupGenerator(&g, MC_1_12_2, 0);

    int64_t worldSeed = -6128692962290639448LL;
    applySeed(&g, 0, worldSeed);

    StrongholdIter sh;
    Pos pos = initFirstStronghold(&sh, MC_1_12_2, worldSeed);

    if (nextStronghold(&sh, &g) <= 0)
        return 1;

    int biomeID = getBiomeAt(&g, 1, sh.pos.x, 63, sh.pos.z);
    printf("X %5d Z %5d (ChunkX %4d ChunkZ %4d) | Biome %2d\n", sh.pos.x, sh.pos.z, sh.pos.x >> 4, sh.pos.z >> 4, biomeID);
    return 0;
}

Adding

case mushroom_field_shore:
    return mc != MC_1_12;

To the finders.c "is valid stronghold biome" function fixes the issue.

xxMattewxx commented 1 year ago

After writing a few more tests, looks like Extreme Hills Edge is also wrong. The following code outputs both Mushroom Field Shore and Extreme Hills Edge as different to vanilla output:

#include "./cubiomes-master/finders.h"
#include <sstream>

int validBiomes[] = { 
    plains, desert, extremeHills, forest, taiga, 
    icePlains, iceMountains, mushroomIsland, desertHills, forestHills, 
    taigaHills, extremeHillsEdge, jungle, jungleHills, jungleEdge,
    stoneBeach, birchForest, birchForestHills, roofedForest, coldTaiga,
    coldTaigaHills, megaTaiga, megaTaigaHills, extremeHillsPlus, savanna,
    savannaPlateau, mesa, mesaPlateau_F, mesaPlateau, sunflower_plains,
    desert_lakes, gravelly_mountains, flower_forest, taiga_mountains, ice_spikes,
    modified_jungle, modified_jungle_edge, tall_birch_forest, tall_birch_hills, 
    dark_forest_hills, snowy_taiga_mountains, giant_spruce_taiga, giant_spruce_taiga_hills,
    modified_gravelly_mountains, shattered_savanna, shattered_savanna_plateau, eroded_badlands,
    modified_wooded_badlands_plateau, modified_badlands_plateau
};

int invalidBiomes[] = {
    ocean, swampland, river, frozenOcean, frozenRiver, 
    mushroomIslandShore, beach, deepOcean, coldBeach, swamp_hills
};

void assert(int id, bool actual, bool expected) {
    printf("-> Biome ID %d %s | Expected %d, got %d\n", id, actual == expected ? "passed" : "rejected", expected, actual);
    if(actual != expected) exit(1);
}

int main(int argc, char** argv) {
    Generator g;
    setupGenerator(&g, MC_1_12_2, 0);

    printf("Performing valid biome list check...\n");
    for(int i = 0; i < sizeof(validBiomes) / sizeof(*validBiomes); i++) { 
        assert(validBiomes[i], isStrongholdBiome(MC_1_12, validBiomes[i]), true);
    }

    printf("Performing invalid biome list check...\n");
    for(int i = 0; i < sizeof(invalidBiomes) / sizeof(*invalidBiomes); i++) { 
        assert(invalidBiomes[i], isStrongholdBiome(MC_1_12, invalidBiomes[i]), false);
    }
    return 0;
}
Cubitect commented 1 year ago

The mushroom_field_shore was indeed wrong for versions up to 1.12, and is fixed now. However, mountain_edge does not generate after version 1.7.

xxMattewxx commented 1 year ago

Passing the test now, tysm! (weird that the game includes mountain_edge in the valid biome list despite not actually generating it, but then again it also considers Hell and The End as valid ones lol)