Universal minecraft schematics library
- Multi-format support: Sponge (v1/v2/v3), Litematica (v6/v7), Axiom, MCEdit
- Auto-detection of schematic format
- Unified schematic interface across all formats
- Dragonfly integration: implements
world.Structureinterface - Java to Bedrock block conversion via crocon
- Standalone format submodule (no Dragonfly dependency)
Use Go modules:
go get github.com/oriumgames/schem
// Read a schematic (auto-detects format)
structure, err := schem.ReadFile("build.litematic")
if err != nil {
log.Fatal(err)
}
// Place in world
world.Exec(func(tx *world.Tx) {
tx.BuildStructure(pos, structure)
})
// Access underlying format
schematic := structure.Schematic()
width, height, length := schematic.Dimensions()- Sponge Schematic v1/v2/v3 —
.schemfiles, supports biomes and entities - Litematica v6/v7 —
.litematicfiles, supports single-region schematics - Axiom —
.axiomfiles, chunk-based storage with thumbnails - MCEdit —
.schematicfiles, legacy format with block ID/metadata
The format package can be used standalone without Dragonfly dependencies:
import "github.com/oriumgames/schem/format"
// Read schematic
schematic, err := format.ReadFile("build.schem")
// Access data
block := schematic.Block(x, y, z)
entity := schematic.BlockEntity(x, y, z)
biome := schematic.Biome(x, y, z)
// Write to different format
format.WriteFormat(writer, "litematica", schematic)Read(r io.Reader) (*Structure, error)— Read with auto-detectionReadFile(path string) (*Structure, error)— Read from fileReadFormat(r io.Reader, formatID string) (*Structure, error)— Read specific formatWrite(w io.Writer, s *Structure) error— Write in native formatWriteFile(path string, s *Structure) error— Write to fileWriteFormat(w io.Writer, formatID string, s *Structure) error— Write specific formatFormats() []string— List supported format IDs
Detect(data []byte) (string, error)— Auto-detect formatRead(r io.Reader) (Schematic, error)— Read with auto-detectionReadFormat(r io.Reader, formatID string) (Schematic, error)— Read specific formatWrite(w io.Writer, schem Schematic) error— Write in native formatWriteFormat(w io.Writer, formatID string, schem Schematic) error— Write specific format
type Schematic interface {
Dimensions() (width, height, length int)
Offset() (x, y, z int)
SetOffset(x, y, z int)
Block(x, y, z int) *BlockState
SetBlock(x, y, z int, block *BlockState)
BlockEntity(x, y, z int) *BlockEntity
SetBlockEntity(x, y, z int, be *BlockEntity)
Entities() []*Entity
AddEntity(entity *Entity)
RemoveEntity(entity *Entity)
Biome(x, y, z int) string
SetBiome(x, y, z int, biome string)
Metadata() map[string]any
SetMetadata(key string, value any)
Format() string
DataVersion() int
SetDataVersion(version int)
Version() string
}Format detection is automatic based on file structure:
- Axiom: Binary magic number
0x0AE5BB36 - Litematica: Gzip + NBT with
Version(6/7) andRegionstag - Sponge: Gzip + NBT with
Versiontag (1/2/3) - MCEdit: Gzip + NBT with
Materials,Blocks,Datatags
When placing in Dragonfly worlds:
- Java block states are converted to Bedrock using crocon
- Invalid properties are filtered based on Dragonfly's block registry
- Block entity NBT data is preserved and applied
- Air blocks are handled explicitly to clear existing blocks
- Unsupported blocks default to air
// Convert between formats
litematic, _ := format.Read(litematicaFile)
format.WriteFormat(spongeFile, "sponge_v3", litematic)
// Inspect schematic
schematic, _ := format.ReadFile("build.schem")
fmt.Printf("Size: %dx%dx%d\n", schematic.Dimensions())
fmt.Printf("Format: %s\n", schematic.Format())
fmt.Printf("Data Version: %d\n", schematic.DataVersion())
// Modify and save
schematic.SetBlock(0, 0, 0, &format.BlockState{
Name: "minecraft:stone",
})
format.WriteFile(output, schematic)This work is based on pitheguy/schemconvert, hollow-cube/schem, paxxxw/litematic-converter, smylermc/litemapy, df-mc/schematic, justtaldevelops/schem, rubixdev/mcdata, prismarinejs/minecraft-data, maruohon/litematica, schematic-specification.