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

Example doesn't compile #44

Open
hypehuman opened this issue Oct 14, 2017 · 4 comments
Open

Example doesn't compile #44

hypehuman opened this issue Oct 14, 2017 · 4 comments

Comments

@hypehuman
Copy link

hypehuman commented Oct 14, 2017

I tried running the example code on the Introduction page of the wiki, but it doesn't compile against the latest version of the source code. I tried changing it to this:

public static void Replace(string pathToWorld, int oldid, int newid)
{
    NbtWorld world = BetaWorld.Open(pathToWorld);
    var chunkManager = world.GetChunkManager();
    System.Diagnostics.Debug.WriteLine("Num chunks: " + chunkManager.Count());
    foreach (ChunkRef chunk in chunkManager)
    {
        // Process Chunk
        for (int y = 0; y <= 127; y++)
        {
            for (int x = 0; x <= 15; x++)
            {
                for (int z = 0; z <= 15; z++)
                {
                    // Attempt to replace block
                    int oldBlock = chunk.Blocks.GetID(x, y, z);
                    if (oldBlock == oldid)
                    {
                        chunk.Blocks.SetID(x, y, z, newid);
                        chunk.Blocks.SetData(x, y, z, 0);
                        // TileEntity consistency is implicitly maintained
                    }
                }
            }
        }

        // Save after each chunk so we can release unneeded chunks back to the system
        chunkManager.Save();
    }
}

But there are 0 chunks in the ChunkManager when I run it on "Substrate\Substrate.Tests\Data\1_9_2-debug".

@hypehuman
Copy link
Author

hypehuman commented Nov 5, 2017

And if I check out 2.x, I get various exceptions for different worlds. Is to be expected? Is there a version of Substrate that works on Minecraft 1.12+? Otherwise, is there a tool that will allow me to load up a world, programatically read and edit the blocks, and then save? J2Blocks works great, but only in one direction (i.e., it can create and save worlds, but can't load existing ones). Thanks for any guidance you can provide :)

@redwyre
Copy link
Contributor

redwyre commented Nov 6, 2017

For the example, try changing it to use NbtWorld.Open instead of BetaWorld.Open.

Are you getting exceptions in your own worlds with the 2.x code? What kind of exceptions?

I have focused what new work I do on 2.x as it supports the "new" block names, currently up to 1.12.2. I haven't recently tried to load a full world though, so I suspect there may be some problems with some nbt data. If you can give me more info (or the world) I can look into it.

@hypehuman
Copy link
Author

Thanks! The commits write a story: https://github.com/hypehuman/Substrate/tree/hypehuman-debug

This is my attempt to get my world to load with Substrate. First I created a new test that uses my world and attempts to run the example on it. The world comes back null, I think because there was gold ore in my inventory. Then I entered the world and cleared my inventory in-game. After that it does manage to load a non-null world, but it crashes at Chunk 1477 of 2152.

Let me know if anything is unclear.

Thanks!

@hypehuman
Copy link
Author

I have since used Substrate successfully on a few worlds, so the problem appears to be specific to a few of them.

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