Cubitect / cubiomes

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

getStructurePos sometimes gets nether structures wrong #105

Open tristanshin opened 11 months ago

tristanshin commented 11 months ago

Some unexpected behavior include claiming that there is a Bastion where there is instead a Fortress and seemingly always claiming that there is a Fortress.

Example: Running the following code should tell us if there is a Bastion in the 0 0 region, if the biome is valid, and if there is a Fortress in that region.

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

int main() {
    int mc = MC_1_19;
    uint64_t seed = -5890134850431795027;
    int xReg = 0;
    int zReg = 0;

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

    Pos p;
    if (getStructurePos(Bastion, mc, seed, xReg, zReg, &p)) {
        printf("Bastion %d %d\n", p.x, p.z);
        if (isViableStructurePos(Bastion, &g, p.x, p.z, 0))
            printf("Valid biome for bastion\n");
        else
            printf("Invalid biome for bastion (basalt)\n");
    }
    if (getStructurePos(Fortress, mc, seed, xReg, zReg, &p))
        printf("Fortress %d %d\n", p.x, p.z);

    return 0;
}

The output is that there is both a Bastion and a Fortress that attempt to generate at (128, 144), but the biome is invalid. The actual answer is that there is a Fortress in a basalt biome.

Running the code with seed 806261106859363233 and region -1 -1 gives that there is a Fortress at (-432, -192), which is correct, but cubiomes-viewer does not display a Fortress there.

This is possibly related to #62.

As for the function always claiming a Fortress exists, it seems that this line is doing exactly that: https://github.com/Cubitect/cubiomes/blob/4c8b36ea4321a9a5e2211ecc1b0c7bc1eaa3b0ca/finders.c#L257 Not sure if that is intended behavior.