schem

package
v0.0.0-...-cfc9b19 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package schem is the public entry point for the S2D library. It defines the cross-cutting Schematic / Block / UnknownReport types, holds the format-handler registry, and exposes Read which dispatches to a format reader based on the filename.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(h FormatHandler)

Register adds a FormatHandler to the dispatch table. Format-reader packages call this from their init() function.

Types

type BedrockState

type BedrockState struct {
	Name       string
	Properties map[string]any
}

BedrockState is a neutral Bedrock block-state identifier. It is the minecraft: identifier and state properties a consumer should preserve even if its runtime has no concrete behaviour implementation for the block. Properties may be shared between blocks that came from the same source palette entry; call Clone before mutating them.

func (BedrockState) Clone

func (s BedrockState) Clone() BedrockState

Clone returns a copy of the Bedrock state and its property map.

type Block

type Block struct {
	Pos            [3]int       // x, y, z within the schematic local frame
	Block          world.Block  // translated Bedrock block; never nil
	Liquid         world.Liquid // non-nil iff the Java source was waterlogged
	BedrockState   BedrockState // neutral Bedrock identifier/properties
	PaletteIndex   uint32       // source palette index when PaletteIndexOK is true
	PaletteIndexOK bool         // true when the source format had palette indexes
}

Block is one cell in a parsed schematic.

type BlockHandler

type BlockHandler func(Block) error

BlockHandler receives one translated block while scanning a schematic.

type Format

type Format string

Format names a supported on-disk schematic format.

const (
	FormatSpongeV2 Format = "sponge_v2"
	FormatSpongeV3 Format = "sponge_v3"
	FormatLegacy   Format = "legacy_schematic"
)

type FormatHandler

type FormatHandler struct {
	Name       Format
	Extensions []string                                                     // e.g. []string{".schem"}
	Signature  func(headerPeek []byte) bool                                 // optional NBT signature check
	Read       func(io.Reader) (*Schematic, error)                          // materialising reader
	Scan       func(io.Reader, InfoHandler, BlockHandler) (ScanInfo, error) // streaming reader
}

FormatHandler describes one supported on-disk format. Format-reader packages register their handler at init() time.

type InfoHandler

type InfoHandler func(ScanInfo) error

InfoHandler receives schematic metadata before the first scanned block.

type ScanInfo

type ScanInfo struct {
	Format                Format
	Width, Height, Length int
	Offset                [3]int
	PaletteSize           int
	Unknowns              UnknownReport
}

ScanInfo is the metadata returned by Scan after visiting every block.

func Scan

func Scan(filename string, r io.Reader, yield BlockHandler) (ScanInfo, error)

Scan parses a schematic from r and calls yield for each translated block without materialising the full Schematic.Blocks slice.

func ScanWithInfo

func ScanWithInfo(filename string, r io.Reader, onInfo InfoHandler, yield BlockHandler) (ScanInfo, error)

ScanWithInfo parses a schematic from r, calls onInfo once after dimensions are known, then calls yield for each translated block.

type Schematic

type Schematic struct {
	Format                Format
	Width, Height, Length int
	Offset                [3]int
	Blocks                []Block
	Unknowns              UnknownReport
}

Schematic is the parsed result of Read.

func Read

func Read(filename string, r io.Reader) (*Schematic, error)

Read parses a schematic from r. The filename's extension selects the format reader; if no extension matches, Read peeks the gzipped header for an NBT signature.

type UnknownReport

type UnknownReport struct {
	Counts map[string]int
	Total  int
}

UnknownReport tallies cells whose Java state could not be translated. Counts is keyed by the canonical Java state string.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL