Captain-Chaos / WorldPainter

WorldPainter is an interactive graphical map generator for the indie game Minecraft.
http://www.worldpainter.net/
GNU General Public License v3.0
355 stars 58 forks source link

Add support for schem3 #397

Open ALingll opened 3 months ago

ALingll commented 3 months ago

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 commented 3 months ago

Pull Request in #398

ALingll commented 3 months ago

File for testing: 7.3.1test.zip