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

Add support for schem3 #397

Open
ALingll opened this issue May 20, 2024 · 2 comments · May be fixed by #398
Open

Add support for schem3 #397

ALingll opened this issue May 20, 2024 · 2 comments · May be fixed by #398

Comments

@ALingll
Copy link

ALingll commented May 20, 2024

image

Although code for reading schem3 has been added in org.pesoft.worldpainter.layers.bo2.Scheme, due to some reasons, these codes actually cannot run correctly.
Scheme 3 puts all fields in a Component called "schematic", which was placed directly outside in previous versions. As jsons shown below:

Schem3

{
    "": {
        "Schematic": {
            //...
        }
    }
}

Schem2

{
    "": {
         //...
    }
}

So the Version judgment in the code is actually invalid. When running against schem3, these codes will never be able to read the correct Version value, resulting in a default value of "0".

public final class Schem extends AbstractNBTItem implements WPObject {
    @SuppressWarnings("unchecked") // Guaranteed by Minecraft
    public Schem(CompoundTag tag, String fallBackName) {
        super(tag);
        final int version = getInt(TAG_VERSION);    //cont read version in schem3, get value "0"
                //...
        switch (version) {
            case 1:
                //...
                break;
            case 2:
                //...
                break;
            case 3:      //never go into this branch
                //...
                break;
            default:
                throw new IllegalArgumentException("Schem version " + version + " not supported");
        }
'''
@ALingll ALingll linked a pull request May 20, 2024 that will close this issue
@ALingll
Copy link
Author

ALingll commented May 20, 2024

Pull Request in #398

@ALingll
Copy link
Author

ALingll commented May 20, 2024

File for testing:
7.3.1test.zip

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 a pull request may close this issue.

1 participant