Conversation
The Sponge Schematic specification stores BlockData as an array of varints, but builder_read_schematic_blocks reads one raw byte per block. Palette indices below 128 encode as a single byte so small schematics load correctly, while anything with a larger palette desynchronises after the first multi-byte index and almost every block comes out wrong. builder_read_schematic now decodes the varints once into big endian integers appended to the file buffer and points sch_blockdata_array at them, reusing the existing TAG_Int_Array code path. Schematics with 128 or fewer palette entries keep the original single byte path and are unaffected. A truncated BlockData array logs a warning and leaves the remaining blocks empty instead of aborting the load.
Mine-imator only accepted Sponge Schematic version 1 and rejected anything newer with "Unsupported format, version too high". WorldEdit and every other current tool write version 2 or 3 as .schem, so those files could not be opened at all. Version 2 keeps the version 1 layout and renames TileEntities to BlockEntities. Version 3 nests the schematic inside the unnamed root compound and moves Palette, Data and BlockEntities into a Blocks compound. builder_read_schematic now resolves all three layouts and res_load_scenery unwraps the version 3 root. The format check no longer treats a version 3 schematic as a legacy one by comparing the tag type of Blocks, so a legacy Blocks byte array still takes the legacy path. .schem is accepted by the scenery file dialog, drag and drop and asset_exts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Builds on #41, which this branch contains as its first commit.
Problem
builder_read_schematicrejects any schematic whoseVersiontag is above 1:WorldEdit and the other current tools write version 2 and version 3 files with a
.schemextension, so they cannot be opened at all — and.schemis not in the scenery file dialog,asset_loadorasset_extseither.Format differences handled
SchematicSchematic""→SchematicPalettePaletteBlocks.PaletteBlockDataBlockDataBlocks.DataTileEntitiesBlockEntitiesBlocks.BlockEntitiesBlock entity objects carry
IdandPosin all three versions, sobuilder_read_schematic_tile_entitiesworks unchanged once the right list is picked up.Change
builder_read_schematicresolves the palette, block data and block entity list per version.res_load_sceneryunwraps the version 3 root compound.Blocksrather than its value, so a version 3Blockscompound is recognised while a legacy MCEditBlocksbyte array still takes the legacy path..schemadded to the scenery file dialog,asset_loadandasset_exts.Verification
CppGenwas run overGmProjectand reportsSuccess!.CppProject/Generatedis left untouched and needs a CppGen run to pick this up.🤖 Generated with Claude Code