PrismarineJS / prismarine-schematic

Read and write schematic of any minecraft version, provide them in a convenient and stable API
https://prismarine.js.org/prismarine-schematic/
MIT License
21 stars 8 forks source link

Read any schematic #1

Closed rom1504 closed 3 years ago

rom1504 commented 3 years ago
Karang commented 3 years ago

Could be useful too: https://minecraft.gamepedia.com/Schematic_file_format At the bottom of the page, there are links to implementations from different plugins/mods.

Karang commented 3 years ago

It seems like the new standard for schematics is https://github.com/SpongePowered/Schematic-Specification

WorldEdit support it as read and write, while it support the old MCEdit schematic format only for reading: https://github.com/EngineHub/WorldEdit/tree/master/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io

This new format use a palette and encode the version in the file, it is still nbt based.

extremeheat commented 3 years ago

I think it would be a good idea to have some sort of loader to load not just schematics, but any format and be able to load it into something like prismarine-world. It doesn't have to replace this, it can still be a low level loader but it would be much easier to consistently support different formats like construction, schematic, structure, mcstructure, etc. This is what I'm working toward for mceditor, so conceptually it would be done with a schematic world provider, and also an exporter.

rom1504 commented 3 years ago

@extremeheat yeah I think having an exporter to pworld (https://github.com/PrismarineJS/prismarine-schematic/issues/3) can be a good way to have a unified interface with other things. pworld support block stuff of any size, and we can add stuff to it as we go (for example entities can definitely go to pworld)

we could support several formats here

rom1504 commented 3 years ago

thanks @Karang for implementing both sponge and mcedit formats one possible next step is trying to parse a bunch of schematics from https://github.com/rom1504/minecraft-schematics-dataset to check if it works well and add some relevant edge case schematics in tests as part of https://github.com/PrismarineJS/prismarine-schematic/issues/7 I expect we'll hit the problem of version detection and conversion between versions. I'm not sure yet whether we should just group schematics per version or try to unify them all by converting to a single good version (with a bit of loss)

rom1504 commented 3 years ago

working on that now. First I'm trying to do the nbt parsing for all schematics. I found https://static.planetminecraft.com/files/resource_media/schematic/1829/old-fallen-castle-1532283303.schematic that crashes node when trying to parse. Investigating

ok the reason is that it's 424MB after decompression, that's ridiculous, I'll just add a threshold and ignore such schematics

rom1504 commented 3 years ago

https://github.com/Podshot/MCEdit-Unified/blob/master/pymclevel/schematic.py https://github.com/EngineHub/WorldEdit/blob/master/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/MCEditSchematicReader.java

^ references

rom1504 commented 3 years ago

basically done