Skip to content

region.ChunkExists returns true but region.GetChunk returns null for the same coordinates. #70

@niuage

Description

@niuage
private void LoadRegions(string name)
{
    string worldPath = Path.Combine(Application.persistentDataPath, "Nbts", name, "region");

    var regionManager = new AnvilRegionManager(worldPath, new ChunkCache());
    
    int i = 0;
    int blocksPerRegionAxis = 2; // Chunks in a region go from 0 to 31 but this is a test
    ushort[][,,] allRegions = new ushort[regionManager.Count() * blocksPerRegionAxis * blocksPerRegionAxis][,,];

    foreach (IRegion region in regionManager) {
        for (int x = 0; x < blocksPerRegionAxis; x++)
            {
            for (int z = 0; z < blocksPerRegionAxis; z++) {
                if (!region.ChunkExists(x, z)) {
                    Debug.Log($"Missing chunk at {x} - {z}");
                    continue;
                } else {
                    Debug.Log("Chunk exists!!");
                }

                IChunk chunk = region.GetChunk(x, z);

                if (chunk != null) {
                    Console.WriteLine($"  Chunk at X: {chunk.X}, Z: {chunk.Z}");

                    allRegions[i * blocksPerRegionAxis + x * blocksPerRegionAxis + z] = CreateVoxelMapFromSubstrateBlocks(chunk.Blocks);
                    Debug.Log(allRegions[i * blocksPerRegionAxis + x * blocksPerRegionAxis + z]);
                } else {
                    Debug.Log("HOW IS IT POSSIBLE?");
                }
            }
        }
        i += 1;
    }

    // more code...
}

I get quite a few "HOW IS IT POSSIBLE?" in my logs :p I guess it fails to load the chunk? Are there minecraft versions that are not supported by the latest Substrate? Does Substrate work if the world uses the Conquest Reforged mod?

I tried a few different maps, none of them work. Here's a example of what I was trying to load: https://www.planetminecraft.com/project/gothic-german-castle-late-medieval/

I also tried to use AnvilWorld.Open(worldPath) (with a different worldPath), and it says that the loading of level.dat failed.

https://owengage.com/anvil/ this site manages to load the regions and display the world (although a lot of it is purple), and NBTExplorer does as well.

Thanks for any pointers you could give me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions