Cubitect / cubiomes

C library that mimics the Minecraft biome generation.
MIT License
579 stars 104 forks source link

Stronghold location sometimes wildly off in 1.18 #60

Closed orlp closed 2 years ago

orlp commented 2 years ago

Problematic seed: 8606696102824824313

Program reports these strongholds:

Stronghold #1  : (  1884,   1876)
Stronghold #2  : ( -2272,    840)
Stronghold #3  : (   468,  -2172)
Stronghold #4  : ( -3468,   3908)
Stronghold #5  : ( -4784,   -776)
Stronghold #6  : ( -1828,  -5080)
Stronghold #7  : (  3820,  -4216)
Stronghold #8  : (  4692,   1000)
Stronghold #9  : (  1780,   5224)
Stronghold #10 : (  5580,  -6176)
Stronghold #11 : (  8520,  -1836)
Stronghold #12 : (  7224,   3224)

Checking in-game with /locate stronghold we find a stronghold at -1400, 424 (and it is actually there):

image

Chunkbase gets this seed right when put in the experimental 1.18 mode.

Repro program (identical to example in readme, apart from seed):

#include "finders.h"
#include <stdio.h>

int main()
{
    int mc = MC_1_18;
    uint64_t seed = 8606696102824824313LL;

    // Only the first stronghold has a position which can be estimated
    // (+/-112 blocks) without biome check.
    StrongholdIter sh;
    Pos pos = initFirstStronghold(&sh, mc, seed);

    printf("Seed: %" PRId64 "\n", (int64_t) seed);
    printf("Estimated position of first stronghold: (%d, %d)\n", pos.x, pos.z);

    Generator g;
    setupGenerator(&g, mc, 0);
    applySeed(&g, 0, seed);

    pos = getSpawn(&g);
    printf("Spawn: (%d, %d)\n", pos.x, pos.z);

    int i, N = 12;
    for (i = 1; i <= N; i++)
    {
        if (nextStronghold(&sh, &g) <= 0)
            break;
        printf("Stronghold #%-3d: (%6d, %6d)\n", i, sh.pos.x, sh.pos.z);
    }

    return 0;
}
Cubitect commented 2 years ago

Strongholds are very problematic in 1.18-rc3 because of MC-241546 and the positions might not even be consistent for the same seed inside Minecraft because of it. Chunkbase also gets it wrong if you check one of the outer strongholds. It worked for my test seeds, but I will investigate if the accuracy can be improved (although if one is wrong chances are all the following are as well). Thanks for the report though.

orlp commented 2 years ago

I see, I didn't know it was messed up at the origin. Hope it gets resolved soon.

Cubitect commented 2 years ago

It turns out my method of dealing with that MC bug does work after all, but I had two other issues that could result in wrong stronghold positions. This should be fixed now.