Skip to content
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

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

Open
niuage opened this issue Nov 18, 2024 · 1 comment

Comments

@niuage
Copy link

niuage commented Nov 18, 2024

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.

@redwyre
Copy link
Contributor

redwyre commented Dec 30, 2024

It looks like the schema changed enough to make some new files not load. Can you try loading it with the latest 2.x? Either from the 2.x branch or on nuget https://www.nuget.org/packages/minecraft-dotnet.Substrate/

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

No branches or pull requests

2 participants