Giter Club home page Giter Club logo

go-litematica-tools's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.