Skip to content

A Go library for reading and writing litematica and NBT files

License

Notifications You must be signed in to change notification settings

elvis972602/go-litematica-tools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-litematica-tools

go-litematica-tools is a Go library for reading and writing litematica and NBT files.

Installation

go get github.com/elvis972602/go-litematica-tools

Usage

package main

import (
	"github.com/Tnze/go-mc/level/block"
	"github.com/elvis972602/go-litematica-tools/schematic"
	"os"
)

func main() {
	// create project
	project := schematic.NewProject("Test", 16, 16, 16)

	// set block
	project.SetBlock(0, 0, 0, block.Dirt{})

	// get block
	block := project.GetBlock(0, 0, 0)

	// encode
	file, err := os.Create("test.litematic")
	if err != nil {
		panic(err)
	}
	defer file.Close()
	project.Encode(file)

	// read file
	file, err := os.Open("test.litematic")
	if err != nil {
		panic(err)
	}
	defer file.Close()
	project, err := schematic.LoadFromFile(file)
	if err != nil {
		panic(err)
	}
}

API

func NewProject

func NewProject(name string, x, y, z int) *Project

NewProject creates a new Project instance with the given name and dimensions.

func LoadFromFile

func LoadFromFile(file *os.File) (*Project, error)

LoadFromFile reads a litematica or NBT file and returns a Project instance.

func (p *Project) SetBlock

func (p *Project) SetBlock(x, y, z int, b BlockState)

SetBlock sets the block at the given coordinates to the given block.

func (p *Project) GetBlock

func (p *Project) GetBlock(x, y, z int) BlockState

GetBlock returns the block at the given coordinates.

func (p *Project) Encode

func (p *Project) Encode(w io.Writer) error

Encode encodes the project as a litematica file.

License

This library is released under the MIT license. See LICENSE for more details.

Note: This README was generated with assistance from GPT-3

About

A Go library for reading and writing litematica and NBT files

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages