schematic

package module
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2022 License: MIT Imports: 10 Imported by: 1

README

Schematic

Schematic is a library for Dragonfly implementing schematics support. The Schematic type implements Dragonfly's world.Structure interface, so that schematics may be pasted with a high throughput.

Installation

Schematic requires at least Go 1.13. The library may be installed using:

go get github.com/df-mc/schematic

Usage

The basic method to get and use a Schematic struct is using the FromReader function:

package main

import (
	"github.com/df-mc/dragonfly/dragonfly/world"
	"github.com/df-mc/schematic"
	"os"
)

func main() {
	file, _ := os.Open("file.schematic")
	s, _ := schematic.FromReader(file)
	
	var w *world.World
	w.BuildStructure(world.BlockPos{}, s)
}

Module documentation

Schematic has a very simple interface. The package documentation can be found here.

Contributing

We use JetBrains Space to manage our issues, pull requests and code reviews, but we welcome contributions through GitHub issues and pull requests.

Contact

Chat on Discord

Documentation

Overview

Package schematic implements the parsing of Schematic files for Dragonfly. Due to the format of schematics, only blocks with an ID smaller than 256 are supported. This means that new blocks are not supported. Due to new blocks not being supported, this package does not provide methods to save blocks to a schematic.

The Schematic struct provided by the schematic package implements Dragonfly's world.Structure interface, allowing for a high throughput for schematic pasting and easy usage. See World.BuildStructure for pasting a schematic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Schematic

type Schematic struct {
	// contains filtered or unexported fields
}

Schematic represents a parsed schematic with blocks in it. It may be used to read blocks from.

func FromReader

func FromReader(r io.Reader) (Schematic, error)

FromReader attempts to read a Schematic from an io.Reader passed. If successful, the schematic with all its data is returned.

func (Schematic) At

func (s Schematic) At(x, y, z int, _ func(int, int, int) world.Block) (world.Block, world.Liquid)

At returns the block found at a given position in the schematic. If any of the X, Y or Z coordinates passed are out of the bounds of the schematic, At will panic.

func (Schematic) Dimensions

func (s Schematic) Dimensions() [3]int

Dimensions returns the dimensions of the schematic as width, height and length respectively.

Jump to

Keyboard shortcuts

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