8000 Add ore generation (1.13 to 1.21.5) by xpple · Pull Request #142 · Cubitect/cubiomes · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add ore generation (1.13 to 1.21.5) #142

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 39 commits into
base: master
Choose a base branch
from

Conversation

xpple
Copy link
@xpple xpple commented Apr 20, 2025

This PR adds ore generation for Minecraft versions 1.13-1.21.5. There are a few cases where the results may be off. These are in places where the vanilla code relies on the terrain, which Cubiomes cannot simulate. How should we handle this? This applies especially in the nether and in caves, because there are a lot of air-exposed ore locations there.

The 1.13-1.17.1 code is mostly ported from SeedFinding/mc_feature_java.

NB: As you will undoubtedly realise, I am not a C programmer. Please excuse me if I didn't do certain things the most idiomatic way. Feel free to edit my branch if you deem necessary.

Example simplified usage (1.18+):
#include "finders.h"
#include "generator.h"
#include <stdio.h>

#include "util.h"

int main() {
    uint64_t seed = 0ULL;
    int version = MC_NEWEST;
    int oreType = DiamondOre;
    Generator g;
    setupGenerator(&g, version, 0);
    applySeed(&g, DIM_OVERWORLD, seed);
    SurfaceNoise sn;
    initSurfaceNoise(&sn, DIM_OVERWORLD, seed);

    int chunkX = 0;
    int chunkZ = 0;

    int viable = 0;
    // check certain Y-coordinates for biomes that are viable for the ore
    int ys[3] = {-30, 64, 120};
    for (int i = 0; i < 3; i++) {
        int biome = getBiomeForOreGen(&g, chunkX, chunkZ, ys[i]);
        viable |= isViableOreBiome(g.mc, oreType, biome);
    }

    if (!viable) {
        printf("Ore does not generate in this chunk.");
        return 0;
    }

    OreConfig oconf;
    if (getOreConfig(oreType, version, -1, &oconf) == 0) {
        printf("Invalid version for ore type.");
        return 0;
    }

    Pos3List pos3List = generateOres(&g, &sn, oconf, chunkX, chunkZ);
    int size = pos3List.size;
    Pos3* pos3s = pos3List.pos3s;
    for (int i = 0; i < size; ++i) {
        printf("Found ore at %d %d %d.\n", pos3s[i].x, pos3s[i].y, pos3s[i].z);
    }
    freePos3List(&pos3List);
    return 1;
}

In reality, the game compiles a list of all viable ores given the biomes (in biome scale) in a 3x3 square of chunks around a central chunk. In order of the index, it then generates all ores, whilst respecting the replaceables and biome (at block scale) of each ore. A function that computes this could be added, but this implementation is meant to provide people with an entrypoint to do such things. As such I have not added it.

Would close Cubitect/cubiomes-viewer#323.

@xpple xpple changed the title Add ore generation (1.13 to 1.17.1) Add ore generation (1.13 to 1.18.2) Apr 22, 2025
@xpple xpple changed the title Add ore generation (1.13 to 1.18.2) Add ore generation (1.13 to 1.21.5) Apr 24, 2025
@xpple xpple marked this pull request as ready for review May 1, 2025 12:30
@xpple
Copy link
Author
xpple commented May 16, 2025

After ores the only logical next step was ore veins, so I have also added those to my fork. However, to prevent scope creep (ore veins do not depend on the biome at all, after all this is Cubiomes), I have decided not to include them in this PR. The code is quite short though and hasn't changed since 1.18, so if you think it fits I can always add it.

@thecraxyhub
Copy link

**wow this should be add with gui
**

@xpple xpple force-pushed the ore-generation branch from f76f02d to a7cd676 Compare May 22, 2025 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

suggestion: ore vein finder
2 participants
0