https://github.com/uberswe/mcnbt
MC-NBT is a Go library for working with Minecraft NBT (Named Binary Tag) data, specifically focused on schematic formats used in Minecraft.
https://github.com/uberswe/mcnbt
create-mod litematica minecraft nbt nbt-parser schematics worldedit
Last synced: 11 months ago
JSON representation
MC-NBT is a Go library for working with Minecraft NBT (Named Binary Tag) data, specifically focused on schematic formats used in Minecraft.
- Host: GitHub
- URL: https://github.com/uberswe/mcnbt
- Owner: uberswe
- Created: 2025-07-09T19:37:02.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-07-14T22:49:11.000Z (11 months ago)
- Last Synced: 2025-07-15T03:08:11.038Z (11 months ago)
- Topics: create-mod, litematica, minecraft, nbt, nbt-parser, schematics, worldedit
- Language: Go
- Homepage:
- Size: 153 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# MC-NBT
MC-NBT is a Go library for working with Minecraft NBT (Named Binary Tag) data, specifically focused on schematic formats used in Minecraft.
## Features
- Parse and decode NBT data from various Minecraft schematic formats:
- Litematica (.litematic)
- WorldEdit (.schem)
- Create (.nbt)
- Convert between different schematic formats
- Unified standard format that consolidates blocks, entities, and tile entities
- Encode and save schematics in any supported format
## Standard Format
The library uses a standard format that can represent any of the supported schematic formats. This standard format consolidates blocks, entities, and tile entities into a single data structure, making it easier to work with and convert between formats.
The `StandardBlock` type represents blocks, entities, and tile entities with a `Type` field to distinguish between them:
- `"block"` for regular blocks
- `"entity"` for entities
- `"tile_entity"` for tile entities (block entities)
## Usage
### Parsing a Schematic
```go
// Parse a schematic file
data, err := mcnbt.ParseAnyFromFileAsJSON("path/to/schematic.litematic")
if err != nil {
// Handle error
}
// Convert to standard format
standard, err := mcnbt.ConvertToStandard(data)
if err != nil {
// Handle error
}
// Access blocks, entities, and tile entities
for _, block := range standard.Blocks {
switch block.Type {
case "block":
// Handle block
case "entity":
// Handle entity
case "tile_entity":
// Handle tile entity
}
}
```
### Converting Between Formats
```go
// Parse a schematic file
data, err := mcnbt.ParseAnyFromFileAsJSON("path/to/schematic.litematic")
if err != nil {
// Handle error
}
// Convert to standard format
standard, err := mcnbt.ConvertToStandard(data)
if err != nil {
// Handle error
}
// Convert to another format
worldEdit, err := mcnbt.ConvertFromStandard(standard, "worldedit")
if err != nil {
// Handle error
}
// Save to file
err = mcnbt.EncodeToFile(worldEdit, "worldedit", "path/to/output.schem")
if err != nil {
// Handle error
}
```
## Supported Formats
### Litematica (.litematic)
Litematica is a mod for Minecraft that allows players to create and place schematics. The library supports parsing and creating Litematica schematics.
### WorldEdit (.schem)
WorldEdit is a popular in-game map editor for Minecraft. The library supports parsing and creating WorldEdit schematics.
### Create (.nbt)
Create is a mod for Minecraft that adds various mechanical blocks and tools. The library supports parsing and creating Create schematics.
## Notes
- When converting between formats, some data loss may occur, especially for entities and tile entities, as different formats support different features.
- The library focuses on preserving block data during conversion, while entity and tile entity data may be simplified or lost.