nbt

package
v0.0.0-...-81a7bf7 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2022 License: ISC, ISC Imports: 5 Imported by: 0

README

nbt

-- import "vimagination.zapto.org/minecraft/nbt"

Package nbt implements a full Named Binary Tag reader/writer, based on the specs

at

http://web.archive.org/web/20110723210920/http://www.minecraft.net/docs/NBT.txt

Usage

var ErrBadRange = errors.New("given index was out-of-range")

ErrBadRange is an error that occurs when trying to set an item on a list which is outside of the current limits of the list.

func Encode
func Encode(w io.Writer, t Tag) error

Encode will encode a single tag to the writer using the default settings

type Bool
type Bool bool

Bool is an implementation of the Data interface

func (Bool) Copy
func (b Bool) Copy() Data

Copy simply returns a copy the the data

func (Bool) Equal
func (b Bool) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (Bool) String
func (b Bool) String() string
func (Bool) Type
func (Bool) Type() TagID

Type returns the TagID of the data

type Byte
type Byte int8

Byte is an implementation of the Data interface NB: Despite being an unsigned integer, it is still called a byte to match the spec.

func (Byte) Copy
func (b Byte) Copy() Data

Copy simply returns a copy the the data

func (Byte) Equal
func (b Byte) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (Byte) String
func (b Byte) String() string
func (Byte) Type
func (Byte) Type() TagID

Type returns the TagID of the data

type ByteArray
type ByteArray []int8

ByteArray is an implementation of the Data interface

func (ByteArray) Bytes
func (b ByteArray) Bytes() []byte

Bytes converts the ByteArray (actually int8) to an actual slice of bytes. NB: May uss unsafe, so the underlying array may be the same.

func (ByteArray) Copy
func (b ByteArray) Copy() Data

Copy simply returns a copy the the data

func (ByteArray) Equal
func (b ByteArray) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (ByteArray) String
func (b ByteArray) String() string
func (ByteArray) Type
func (ByteArray) Type() TagID

Type returns the TagID of the data

type Complex128
type Complex128 complex128

Complex128 is an implementation of the Data interface

func (Complex128) Copy
func (c Complex128) Copy() Data

Copy simply returns a copy the the data

func (Complex128) Equal
func (c Complex128) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (Complex128) String
func (c Complex128) String() string
func (Complex128) Type
func (Complex128) Type() TagID

Type returns the TagID of the data

type Complex64
type Complex64 complex64

Complex64 is an implementation of the Data interface

func (Complex64) Copy
func (c Complex64) Copy() Data

Copy simply returns a copy the the data

func (Complex64) Equal
func (c Complex64) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (Complex64) String
func (c Complex64) String() string
func (Complex64) Type
func (Complex64) Type() TagID

Type returns the TagID of the data

type Compound
type Compound []Tag

Compound is an implementation of the Data interface

func (Compound) Copy
func (c Compound) Copy() Data

Copy simply returns a deep-copy the the data

func (Compound) Equal
func (c Compound) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (Compound) Get
func (c Compound) Get(name string) Tag

Get returns the tag for the given name

func (*Compound) Remove
func (c *Compound) Remove(name string)

Remove removes the tag corresponding to the given name

func (*Compound) Set
func (c *Compound) Set(tag Tag)

Set adds the given tag to the compound, or, if the tags name is already present, overrides the old data

func (Compound) String
func (c Compound) String() string
func (Compound) Type
func (Compound) Type() TagID

Type returns the TagID of the data

type Data
type Data interface {
	Equal(interface{}) bool
	Copy() Data
	String() string
	Type() TagID
}

Data is an interface representing the many different types that a tag can be

type Decoder
type Decoder struct {
}

Decoder is a type used to decode NBT streams

func NewDecoder
func NewDecoder(r io.Reader) Decoder

NewDecoder returns a Decoder using Big Endian

func NewDecoderEndian
func NewDecoderEndian(e byteio.EndianReader) Decoder

NewDecoderEndian allows you to specify your own Endian Reader

func (Decoder) Decode
func (d Decoder) Decode() (Tag, error)

Decode will read a whole tag out of the decoding stream

type Double
type Double float64

Double is an implementation of the Data interface

func (Double) Copy
func (d Double) Copy() Data

Copy simply returns a copy the the data

func (Double) Equal
func (d Double) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (Double) String
func (d Double) String() string
func (Double) Type
func (Double) Type() TagID

Type returns the TagID of the data

type Encoder
type Encoder struct {
}

Encoder is a type used to encode NBT streams

func NewEncoder
func NewEncoder(w io.Writer) Encoder

NewEncoder returns an Encoder using Big Endian

func NewEncoderEndian
func NewEncoderEndian(e byteio.EndianWriter) Encoder

NewEncoderEndian allows you to specify your own Endian Writer

func (Encoder) Encode
func (e Encoder) Encode(t Tag) error

Encode will encode a whole tag to the encoding stream

type Float
type Float float32

Float is an implementation of the Data interface

func (Float) Copy
func (f Float) Copy() Data

Copy simply returns a copy the the data

func (Float) Equal
func (f Float) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (Float) String
func (f Float) String() string
func (Float) Type
func (Float) Type() TagID

Type returns the TagID of the data

type Int
type Int int32

Int is an implementation of the Data interface

func (Int) Copy
func (i Int) Copy() Data

Copy simply returns a copy the the data

func (Int) Equal
func (i Int) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (Int) String
func (i Int) String() string
func (Int) Type
func (Int) Type() TagID

Type returns the TagID of the data

type IntArray
type IntArray []int32

IntArray is an implementation of the Data interface

func (IntArray) Copy
func (i IntArray) Copy() Data

Copy simply returns a copy the the data

func (IntArray) Equal
func (i IntArray) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (IntArray) String
func (i IntArray) String() string
func (IntArray) Type
func (IntArray) Type() TagID

Type returns the TagID of the data

type List
type List interface {
	Data
	Set(int, Data) error
	Get(int) Data
	Append(...Data) error
	Insert(int, ...Data) error
	Remove(int)
	Len() int
	TagType() TagID
}

List interface descibes the methods for the lists of different data types

func NewEmptyList
func NewEmptyList(tagType TagID) List

NewEmptyList returns a new empty List Data type, set to the type given

func NewList
func NewList(data []Data) List

NewList returns a new List Data type, or nil if the given data is not of all the same Data type

type ListBool
type ListBool []Bool

ListBool satisfies the List interface for a list of Bools

func (*ListBool) Append
func (l *ListBool) Append(d ...Data) error

Append adds data to the list

func (ListBool) Copy
func (l ListBool) Copy() Data

Copy simply returns a deep-copy the the data

func (ListBool) Equal
func (l ListBool) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (ListBool) Get
func (l ListBool) Get(i int) Data

Get returns the data at the given positon

func (*ListBool) Insert
func (l *ListBool) Insert(i int, d ...Data) error

Insert will add the given data at the specified position, moving other up

func (ListBool) Len
func (l ListBool) Len() int

Len returns the length of the list

func (*ListBool) Remove
func (l *ListBool) Remove(i int)

Remove deletes the specified position and shifts remaing data down

func (ListBool) Set
func (l ListBool) Set(i int, d Data) error

Set sets the data at the given position. It does not append

func (ListBool) String
func (l ListBool) String() string
func (ListBool) TagType
func (ListBool) TagType() TagID

TagType returns the TagID of the type of tag this list contains

func (ListBool) Type
func (ListBool) Type() TagID

Type returns the TagID of the data

type ListByte
type ListByte []Byte

ListByte satisfies the List interface for a list of Bytes

func (*ListByte) Append
func (l *ListByte) Append(d ...Data) error

Append adds data to the list

func (ListByte) Copy
func (l ListByte) Copy() Data

Copy simply returns a deep-copy the the data

func (ListByte) Equal
func (l ListByte) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (ListByte) Get
func (l ListByte) Get(i int) Data

Get returns the data at the given positon

func (*ListByte) Insert
func (l *ListByte) Insert(i int, d ...Data) error

Insert will add the given data at the specified position, moving other up

func (ListByte) Len
func (l ListByte) Len() int

Len returns the length of the list

func (*ListByte) Remove
func (l *ListByte) Remove(i int)

Remove deletes the specified position and shifts remaing data down

func (ListByte) Set
func (l ListByte) Set(i int, d Data) error

Set sets the data at the given position. It does not append

func (ListByte) String
func (l ListByte) String() string
func (ListByte) TagType
func (ListByte) TagType() TagID

TagType returns the TagID of the type of tag this list contains

func (ListByte) Type
func (ListByte) Type() TagID

Type returns the TagID of the data

type ListComplex128
type ListComplex128 []Complex128

ListComplex128 satisfies the List interface for a list of Complex128s

func (*ListComplex128) Append
func (l *ListComplex128) Append(d ...Data) error

Append adds data to the list

func (ListComplex128) Copy
func (l ListComplex128) Copy() Data

Copy simply returns a deep-copy the the data

func (ListComplex128) Equal
func (l ListComplex128) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (ListComplex128) Get
func (l ListComplex128) Get(i int) Data

Get returns the data at the given positon

func (*ListComplex128) Insert
func (l *ListComplex128) Insert(i int, d ...Data) error

Insert will add the given data at the specified position, moving other up

func (ListComplex128) Len
func (l ListComplex128) Len() int

Len returns the length of the list

func (*ListComplex128) Remove
func (l *ListComplex128) Remove(i int)

Remove deletes the specified position and shifts remaing data down

func (ListComplex128) Set
func (l ListComplex128) Set(i int, d Data) error

Set sets the data at the given position. It does not append

func (ListComplex128) String
func (l ListComplex128) String() string
func (ListComplex128) TagType
func (ListComplex128) TagType() TagID

TagType returns the TagID of the type of tag this list contains

func (ListComplex128) Type
func (ListComplex128) Type() TagID

Type returns the TagID of the data

type ListComplex64
type ListComplex64 []Complex64

ListComplex64 satisfies the List interface for a list of Complex64s

func (*ListComplex64) Append
func (l *ListComplex64) Append(d ...Data) error

Append adds data to the list

func (ListComplex64) Copy
func (l ListComplex64) Copy() Data

Copy simply returns a deep-copy the the data

func (ListComplex64) Equal
func (l ListComplex64) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (ListComplex64) Get
func (l ListComplex64) Get(i int) Data

Get returns the data at the given positon

func (*ListComplex64) Insert
func (l *ListComplex64) Insert(i int, d ...Data) error

Insert will add the given data at the specified position, moving other up

func (ListComplex64) Len
func (l ListComplex64) Len() int

Len returns the length of the list

func (*ListComplex64) Remove
func (l *ListComplex64) Remove(i int)

Remove deletes the specified position and shifts remaing data down

func (ListComplex64) Set
func (l ListComplex64) Set(i int, d Data) error

Set sets the data at the given position. It does not append

func (ListComplex64) String
func (l ListComplex64) String() string
func (ListComplex64) TagType
func (ListComplex64) TagType() TagID

TagType returns the TagID of the type of tag this list contains

func (ListComplex64) Type
func (ListComplex64) Type() TagID

Type returns the TagID of the data

type ListCompound
type ListCompound []Compound

ListCompound satisfies the List interface for a list of Compounds

func (*ListCompound) Append
func (l *ListCompound) Append(d ...Data) error

Append adds data to the list

func (ListCompound) Copy
func (l ListCompound) Copy() Data

Copy simply returns a deep-copy the the data

func (ListCompound) Equal
func (l ListCompound) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (ListCompound) Get
func (l ListCompound) Get(i int) Data

Get returns the data at the given positon

func (*ListCompound) Insert
func (l *ListCompound) Insert(i int, d ...Data) error

Insert will add the given data at the specified position, moving other up

func (ListCompound) Len
func (l ListCompound) Len() int

Len returns the length of the list

func (*ListCompound) Remove
func (l *ListCompound) Remove(i int)

Remove deletes the specified position and shifts remaing data down

func (ListCompound) Set
func (l ListCompound) Set(i int, d Data) error

Set sets the data at the given position. It does not append

func (ListCompound) String
func (l ListCompound) String() string
func (ListCompound) TagType
func (ListCompound) TagType() TagID

TagType returns the TagID of the type of tag this list contains

func (ListCompound) Type
func (ListCompound) Type() TagID

Type returns the TagID of the data

type ListData
type ListData struct {
}

ListData is an implementation of the Data interface

func (*ListData) Append
func (l *ListData) Append(data ...Data) error

Append adds data to the list

func (*ListData) Copy
func (l *ListData) Copy() Data

Copy simply returns a deep-copy the the data

func (*ListData) Equal
func (l *ListData) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (*ListData) Get
func (l *ListData) Get(i int) Data

Get returns the data at the given positon

func (*ListData) Insert
func (l *ListData) Insert(i int, data ...Data) error

Insert will add the given data at the specified position, moving other elements up.

func (*ListData) Len
func (l *ListData) Len() int

Len returns the length of the list

func (ListData) ListBool
func (l ListData) ListBool() ListBool

ListBool returns the list as a specifically typed List

func (ListData) ListByte
func (l ListData) ListByte() ListByte

ListByte returns the list as a specifically typed List

func (ListData) ListComplex128
func (l ListData) ListComplex128() ListComplex128

ListComplex128 returns the list as a specifically typed List

func (ListData) ListComplex64
func (l ListData) ListComplex64() ListComplex64

ListComplex64 returns the list as a specifically typed List

func (ListData) ListCompound
func (l ListData) ListCompound() ListCompound

ListCompound returns the list as a specifically typed List

func (ListData) ListDouble
func (l ListData) ListDouble() ListDouble

ListDouble returns the list as a specifically typed List

func (ListData) ListEnd
func (l ListData) ListEnd() ListEnd

ListEnd returns the list as a specifically typed List

func (ListData) ListFloat
func (l ListData) ListFloat() ListFloat

ListFloat returns the list as a specifically typed List

func (ListData) ListInt
func (l ListData) ListInt() ListInt

ListInt returns the list as a specifically typed List

func (ListData) ListIntArray
func (l ListData) ListIntArray() ListIntArray

ListIntArray returns the list as a specifically typed List

func (ListData) ListLong
func (l ListData) ListLong() ListLong

ListLong returns the list as a specifically typed List

func (ListData) ListShort
func (l ListData) ListShort() ListShort

ListShort returns the list as a specifically typed List

func (ListData) ListUint16
func (l ListData) ListUint16() ListUint16

ListUint16 returns the list as a specifically typed List

func (ListData) ListUint32
func (l ListData) ListUint32() ListUint32

ListUint32 returns the list as a specifically typed List

func (ListData) ListUint64
func (l ListData) ListUint64() ListUint64

ListUint64 returns the list as a specifically typed List

func (ListData) ListUint8
func (l ListData) ListUint8() ListUint8

ListUint8 returns the list as a specifically typed List

func (*ListData) Remove
func (l *ListData) Remove(i int)

Remove deletes the specified position and shifts remaing data down

func (*ListData) Set
func (l *ListData) Set(i int, data Data) error

Set sets the data at the given position. It does not append

func (*ListData) String
func (l *ListData) String() string
func (*ListData) TagType
func (l *ListData) TagType() TagID

TagType returns the TagID of the type of tag this list contains

func (ListData) Type
func (ListData) Type() TagID

Type returns the TagID of the data

type ListDouble
type ListDouble []Double

ListDouble satisfies the List interface for a list of Doubles

func (*ListDouble) Append
func (l *ListDouble) Append(d ...Data) error

Append adds data to the list

func (ListDouble) Copy
func (l ListDouble) Copy() Data

Copy simply returns a deep-copy the the data

func (ListDouble) Equal
func (l ListDouble) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (ListDouble) Get
func (l ListDouble) Get(i int) Data

Get returns the data at the given positon

func (*ListDouble) Insert
func (l *ListDouble) Insert(i int, d ...Data) error

Insert will add the given data at the specified position, moving other up

func (ListDouble) Len
func (l ListDouble) Len() int

Len returns the length of the list

func (*ListDouble) Remove
func (l *ListDouble) Remove(i int)

Remove deletes the specified position and shifts remaing data down

func (ListDouble) Set
func (l ListDouble) Set(i int, d Data) error

Set sets the data at the given position. It does not append

func (ListDouble) String
func (l ListDouble) String() string
func (ListDouble) TagType
func (ListDouble) TagType() TagID

TagType returns the TagID of the type of tag this list contains

func (ListDouble) Type
func (ListDouble) Type() TagID

Type returns the TagID of the data

type ListEnd
type ListEnd uint32

ListEnd satisfies the List interface for a list of Ends

func (*ListEnd) Append
func (l *ListEnd) Append(d ...Data) error

Append adds to the list

func (ListEnd) Copy
func (l ListEnd) Copy() Data

Copy simply returns a deep-copy the the data

func (ListEnd) Equal
func (l ListEnd) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (ListEnd) Get
func (ListEnd) Get(_ int) Data

Get returns an end{}

func (*ListEnd) Insert
func (l *ListEnd) Insert(_ int, d ...Data) error

Insert adds to the list

func (ListEnd) Len
func (l ListEnd) Len() int

Len returns the length of the List

func (*ListEnd) Remove
func (l *ListEnd) Remove(i int)

Remove removes from the list

func (ListEnd) Set
func (l ListEnd) Set(_ int, d Data) error

Set does nothing as it's not applicable for ListEnd

func (ListEnd) String
func (l ListEnd) String() string
func (ListEnd) TagType
func (ListEnd) TagType() TagID

TagType returns the TagID of the type of tag this list contains

func (ListEnd) Type
func (ListEnd) Type() TagID

Type returns the TagID of the data

type ListFloat
type ListFloat []Float

ListFloat satisfies the List interface for a list of Floats

func (*ListFloat) Append
func (l *ListFloat) Append(d ...Data) error

Append adds data to the list

func (ListFloat) Copy
func (l ListFloat) Copy() Data

Copy simply returns a deep-copy the the data

func (ListFloat) Equal
func (l ListFloat) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (ListFloat) Get
func (l ListFloat) Get(i int) Data

Get returns the data at the given positon

func (*ListFloat) Insert
func (l *ListFloat) Insert(i int, d ...Data) error

Insert will add the given data at the specified position, moving other up

func (ListFloat) Len
func (l ListFloat) Len() int

Len returns the length of the list

func (*ListFloat) Remove
func (l *ListFloat) Remove(i int)

Remove deletes the specified position and shifts remaing data down

func (ListFloat) Set
func (l ListFloat) Set(i int, d Data) error

Set sets the data at the given position. It does not append

func (ListFloat) String
func (l ListFloat) String() string
func (ListFloat) TagType
func (ListFloat) TagType() TagID

TagType returns the TagID of the type of tag this list contains

func (ListFloat) Type
func (ListFloat) Type() TagID

Type returns the TagID of the data

type ListInt
type ListInt []Int

ListInt satisfies the List interface for a list of Ints

func (*ListInt) Append
func (l *ListInt) Append(d ...Data) error

Append adds data to the list

func (ListInt) Copy
func (l ListInt) Copy() Data

Copy simply returns a deep-copy the the data

func (ListInt) Equal
func (l ListInt) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (ListInt) Get
func (l ListInt) Get(i int) Data

Get returns the data at the given positon

func (*ListInt) Insert
func (l *ListInt) Insert(i int, d ...Data) error

Insert will add the given data at the specified position, moving other up

func (ListInt) Len
func (l ListInt) Len() int

Len returns the length of the list

func (*ListInt) Remove
func (l *ListInt) Remove(i int)

Remove deletes the specified position and shifts remaing data down

func (ListInt) Set
func (l ListInt) Set(i int, d Data) error

Set sets the data at the given position. It does not append

func (ListInt) String
func (l ListInt) String() string
func (ListInt) TagType
func (ListInt) TagType() TagID

TagType returns the TagID of the type of tag this list contains

func (ListInt) Type
func (ListInt) Type() TagID

Type returns the TagID of the data

type ListIntArray
type ListIntArray []IntArray

ListIntArray satisfies the List interface for a list of IntArrays

func (*ListIntArray) Append
func (l *ListIntArray) Append(d ...Data) error

Append adds data to the list

func (ListIntArray) Copy
func (l ListIntArray) Copy() Data

Copy simply returns a deep-copy the the data

func (ListIntArray) Equal
func (l ListIntArray) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (ListIntArray) Get
func (l ListIntArray) Get(i int) Data

Get returns the data at the given positon

func (*ListIntArray) Insert
func (l *ListIntArray) Insert(i int, d ...Data) error

Insert will add the given data at the specified position, moving other up

func (ListIntArray) Len
func (l ListIntArray) Len() int

Len returns the length of the list

func (*ListIntArray) Remove
func (l *ListIntArray) Remove(i int)

Remove deletes the specified position and shifts remaing data down

func (ListIntArray) Set
func (l ListIntArray) Set(i int, d Data) error

Set sets the data at the given position. It does not append

func (ListIntArray) String
func (l ListIntArray) String() string
func (ListIntArray) TagType
func (ListIntArray) TagType() TagID

TagType returns the TagID of the type of tag this list contains

func (ListIntArray) Type
func (ListIntArray) Type() TagID

Type returns the TagID of the data

type ListLong
type ListLong []Long

ListLong satisfies the List interface for a list of Longs

func (*ListLong) Append
func (l *ListLong) Append(d ...Data) error

Append adds data to the list

func (ListLong) Copy
func (l ListLong) Copy() Data

Copy simply returns a deep-copy the the data

func (ListLong) Equal
func (l ListLong) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (ListLong) Get
func (l ListLong) Get(i int) Data

Get returns the data at the given positon

func (*ListLong) Insert
func (l *ListLong) Insert(i int, d ...Data) error

Insert will add the given data at the specified position, moving other up

func (ListLong) Len
func (l ListLong) Len() int

Len returns the length of the list

func (*ListLong) Remove
func (l *ListLong) Remove(i int)

Remove deletes the specified position and shifts remaing data down

func (ListLong) Set
func (l ListLong) Set(i int, d Data) error

Set sets the data at the given position. It does not append

func (ListLong) String
func (l ListLong) String() string
func (ListLong) TagType
func (ListLong) TagType() TagID

TagType returns the TagID of the type of tag this list contains

func (ListLong) Type
func (ListLong) Type() TagID

Type returns the TagID of the data

type ListShort
type ListShort []Short

ListShort satisfies the List interface for a list of Shorts

func (*ListShort) Append
func (l *ListShort) Append(d ...Data) error

Append adds data to the list

func (ListShort) Copy
func (l ListShort) Copy() Data

Copy simply returns a deep-copy the the data

func (ListShort) Equal
func (l ListShort) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (ListShort) Get
func (l ListShort) Get(i int) Data

Get returns the data at the given positon

func (*ListShort) Insert
func (l *ListShort) Insert(i int, d ...Data) error

Insert will add the given data at the specified position, moving other up

func (ListShort) Len
func (l ListShort) Len() int

Len returns the length of the list

func (*ListShort) Remove
func (l *ListShort) Remove(i int)

Remove deletes the specified position and shifts remaing data down

func (ListShort) Set
func (l ListShort) Set(i int, d Data) error

Set sets the data at the given position. It does not append

func (ListShort) String
func (l ListShort) String() string
func (ListShort) TagType
func (ListShort) TagType() TagID

TagType returns the TagID of the type of tag this list contains

func (ListShort) Type
func (ListShort) Type() TagID

Type returns the TagID of the data

type ListUint16
type ListUint16 []Uint16

ListUint16 satisfies the List interface for a list of Uint16s

func (*ListUint16) Append
func (l *ListUint16) Append(d ...Data) error

Append adds data to the list

func (ListUint16) Copy
func (l ListUint16) Copy() Data

Copy simply returns a deep-copy the the data

func (ListUint16) Equal
func (l ListUint16) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (ListUint16) Get
func (l ListUint16) Get(i int) Data

Get returns the data at the given positon

func (*ListUint16) Insert
func (l *ListUint16) Insert(i int, d ...Data) error

Insert will add the given data at the specified position, moving other up

func (ListUint16) Len
func (l ListUint16) Len() int

Len returns the length of the list

func (*ListUint16) Remove
func (l *ListUint16) Remove(i int)

Remove deletes the specified position and shifts remaing data down

func (ListUint16) Set
func (l ListUint16) Set(i int, d Data) error

Set sets the data at the given position. It does not append

func (ListUint16) String
func (l ListUint16) String() string
func (ListUint16) TagType
func (ListUint16) TagType() TagID

TagType returns the TagID of the type of tag this list contains

func (ListUint16) Type
func (ListUint16) Type() TagID

Type returns the TagID of the data

type ListUint32
type ListUint32 []Uint32

ListUint32 satisfies the List interface for a list of Uint32s

func (*ListUint32) Append
func (l *ListUint32) Append(d ...Data) error

Append adds data to the list

func (ListUint32) Copy
func (l ListUint32) Copy() Data

Copy simply returns a deep-copy the the data

func (ListUint32) Equal
func (l ListUint32) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (ListUint32) Get
func (l ListUint32) Get(i int) Data

Get returns the data at the given positon

func (*ListUint32) Insert
func (l *ListUint32) Insert(i int, d ...Data) error

Insert will add the given data at the specified position, moving other up

func (ListUint32) Len
func (l ListUint32) Len() int

Len returns the length of the list

func (*ListUint32) Remove
func (l *ListUint32) Remove(i int)

Remove deletes the specified position and shifts remaing data down

func (ListUint32) Set
func (l ListUint32) Set(i int, d Data) error

Set sets the data at the given position. It does not append

func (ListUint32) String
func (l ListUint32) String() string
func (ListUint32) TagType
func (ListUint32) TagType() TagID

TagType returns the TagID of the type of tag this list contains

func (ListUint32) Type
func (ListUint32) Type() TagID

Type returns the TagID of the data

type ListUint64
type ListUint64 []Uint64

ListUint64 satisfies the List interface for a list of Uint64s

func (*ListUint64) Append
func (l *ListUint64) Append(d ...Data) error

Append adds data to the list

func (ListUint64) Copy
func (l ListUint64) Copy() Data

Copy simply returns a deep-copy the the data

func (ListUint64) Equal
func (l ListUint64) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (ListUint64) Get
func (l ListUint64) Get(i int) Data

Get returns the data at the given positon

func (*ListUint64) Insert
func (l *ListUint64) Insert(i int, d ...Data) error

Insert will add the given data at the specified position, moving other up

func (ListUint64) Len
func (l ListUint64) Len() int

Len returns the length of the list

func (*ListUint64) Remove
func (l *ListUint64) Remove(i int)

Remove deletes the specified position and shifts remaing data down

func (ListUint64) Set
func (l ListUint64) Set(i int, d Data) error

Set sets the data at the given position. It does not append

func (ListUint64) String
func (l ListUint64) String() string
func (ListUint64) TagType
func (ListUint64) TagType() TagID

TagType returns the TagID of the type of tag this list contains

func (ListUint64) Type
func (ListUint64) Type() TagID

Type returns the TagID of the data

type ListUint8
type ListUint8 []Uint8

ListUint8 satisfies the List interface for a list of Uint8s

func (*ListUint8) Append
func (l *ListUint8) Append(d ...Data) error

Append adds data to the list

func (ListUint8) Copy
func (l ListUint8) Copy() Data

Copy simply returns a deep-copy the the data

func (ListUint8) Equal
func (l ListUint8) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (ListUint8) Get
func (l ListUint8) Get(i int) Data

Get returns the data at the given positon

func (*ListUint8) Insert
func (l *ListUint8) Insert(i int, d ...Data) error

Insert will add the given data at the specified position, moving other up

func (ListUint8) Len
func (l ListUint8) Len() int

Len returns the length of the list

func (*ListUint8) Remove
func (l *ListUint8) Remove(i int)

Remove deletes the specified position and shifts remaing data down

func (ListUint8) Set
func (l ListUint8) Set(i int, d Data) error

Set sets the data at the given position. It does not append

func (ListUint8) String
func (l ListUint8) String() string
func (ListUint8) TagType
func (ListUint8) TagType() TagID

TagType returns the TagID of the type of tag this list contains

func (ListUint8) Type
func (ListUint8) Type() TagID

Type returns the TagID of the data

type Long
type Long int64

Long is an implementation of the Data interface

func (Long) Copy
func (l Long) Copy() Data

Copy simply returns a copy the the data

func (Long) Equal
func (l Long) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (Long) String
func (l Long) String() string
func (Long) Type
func (Long) Type() TagID

Type returns the TagID of the data

type ReadError
type ReadError struct {
	Where string
	Err   error
}

ReadError is an error returned when a read error occurs

func (ReadError) Error
func (r ReadError) Error() string
type Short
type Short int16

Short is an implementation of the Data interface

func (Short) Copy
func (s Short) Copy() Data

Copy simply returns a copy the the data

func (Short) Equal
func (s Short) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (Short) String
func (s Short) String() string
func (Short) Type
func (Short) Type() TagID

Type returns the TagID of the data

type String
type String string

String is an implementation of the Data interface

func (String) Copy
func (s String) Copy() Data

Copy simply returns a copy the the data

func (String) Equal
func (s String) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (String) String
func (s String) String() string
func (String) Type
func (String) Type() TagID

Type returns the TagID of the data

type Tag
type Tag struct {
}

Tag is the main NBT type, a combination of a name and a Data type

func Decode
func Decode(r io.Reader) (Tag, error)

Decode will eencode a single tag from the reader using the default settings

func NewTag
func NewTag(name string, d Data) Tag

NewTag constructs a new tag with the given name and data.

func (Tag) Copy
func (t Tag) Copy() Tag

Copy simply returns a deep-copy the the tag

func (Tag) Data
func (t Tag) Data() Data

Data returns the tags data type

func (Tag) Equal
func (t Tag) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (Tag) Name
func (t Tag) Name() string

Name returns the tags' name

func (Tag) String
func (t Tag) String() string

String returns a textual representation of the tag

func (Tag) TagID
func (t Tag) TagID() TagID

TagID returns the type of the data

type TagID
type TagID uint8

TagID represents the type of nbt tag

const (
	TagEnd        TagID = 0
	TagByte       TagID = 1
	TagShort      TagID = 2
	TagInt        TagID = 3
	TagLong       TagID = 4
	TagFloat      TagID = 5
	TagDouble     TagID = 6
	TagByteArray  TagID = 7
	TagString     TagID = 8
	TagList       TagID = 9
	TagCompound   TagID = 10
	TagIntArray   TagID = 11
	TagBool       TagID = 12
	TagUint8      TagID = 13
	TagUint16     TagID = 14
	TagUint32     TagID = 15
	TagUint64     TagID = 16
	TagComplex64  TagID = 17
	TagComplex128 TagID = 18
)

Tag Types

func (TagID) String
func (t TagID) String() string
type Uint16
type Uint16 uint16

Uint16 is an implementation of the Data interface

func (Uint16) Copy
func (u Uint16) Copy() Data

Copy simply returns a copy the the data

func (Uint16) Equal
func (u Uint16) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (Uint16) String
func (u Uint16) String() string
func (Uint16) Type
func (Uint16) Type() TagID

Type returns the TagID of the data

type Uint32
type Uint32 uint32

Uint32 is an implementation of the Data interface

func (Uint32) Copy
func (u Uint32) Copy() Data

Copy simply returns a copy the the data

func (Uint32) Equal
func (u Uint32) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (Uint32) String
func (u Uint32) String() string
func (Uint32) Type
func (Uint32) Type() TagID

Type returns the TagID of the data

type Uint64
type Uint64 uint64

Uint64 is an implementation of the Data interface

func (Uint64) Copy
func (u Uint64) Copy() Data

Copy simply returns a copy the the data

func (Uint64) Equal
func (u Uint64) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (Uint64) String
func (u Uint64) String() string
func (Uint64) Type
func (Uint64) Type() TagID

Type returns the TagID of the data

type Uint8
type Uint8 uint8

Uint8 is an implementation of the Data interface

func (Uint8) Copy
func (u Uint8) Copy() Data

Copy simply returns a copy the the data

func (Uint8) Equal
func (u Uint8) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (Uint8) String
func (u Uint8) String() string
func (Uint8) Type
func (Uint8) Type() TagID

Type returns the TagID of the data

type UnknownTag
type UnknownTag struct {
	TagID
}

UnknownTag is an error that occurs when an unknown tag id is discovered. This could also indicate corrupted or non-compliant data.

func (UnknownTag) Error
func (u UnknownTag) Error() string
type WriteError
type WriteError struct {
	Where string
	Err   error
}

WriteError is an error returned when a write error occurs

func (WriteError) Error
func (w WriteError) Error() string
type WrongTag
type WrongTag struct {
	Expecting, Got TagID
}

WrongTag is an error returned when a tag of the incorrect type was intended to be added to a list.

func (WrongTag) Error
func (w WrongTag) Error() string

Documentation

Overview

Package nbt implements a full Named Binary Tag reader/writer, based on the specs at http://web.archive.org/web/20110723210920/http://www.minecraft.net/docs/NBT.txt

Index

Constants

This section is empty.

Variables

View Source
var ErrBadRange = errors.New("given index was out-of-range")

ErrBadRange is an error that occurs when trying to set an item on a list which is outside of the current limits of the list.

Functions

func Encode

func Encode(w io.Writer, t Tag) error

Encode will encode a single tag to the writer using the default settings

Types

type Bool

type Bool bool

Bool is an implementation of the Data interface

func (Bool) Copy

func (b Bool) Copy() Data

Copy simply returns a copy the the data

func (Bool) Equal

func (b Bool) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (Bool) String

func (b Bool) String() string

func (Bool) Type

func (Bool) Type() TagID

Type returns the TagID of the data

type Byte

type Byte int8

Byte is an implementation of the Data interface NB: Despite being an unsigned integer, it is still called a byte to match the spec.

func (Byte) Copy

func (b Byte) Copy() Data

Copy simply returns a copy the the data

func (Byte) Equal

func (b Byte) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (Byte) String

func (b Byte) String() string

func (Byte) Type

func (Byte) Type() TagID

Type returns the TagID of the data

type ByteArray

type ByteArray []int8

ByteArray is an implementation of the Data interface

func (ByteArray) Bytes

func (b ByteArray) Bytes() []byte

Bytes converts the ByteArray (actually int8) to an actual slice of bytes. NB: May uss unsafe, so the underlying array may be the same.

func (ByteArray) Copy

func (b ByteArray) Copy() Data

Copy simply returns a copy the the data

func (ByteArray) Equal

func (b ByteArray) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (ByteArray) String

func (b ByteArray) String() string

func (ByteArray) Type

func (ByteArray) Type() TagID

Type returns the TagID of the data

type Complex128

type Complex128 complex128

Complex128 is an implementation of the Data interface

func (Complex128) Copy

func (c Complex128) Copy() Data

Copy simply returns a copy the the data

func (Complex128) Equal

func (c Complex128) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (Complex128) String

func (c Complex128) String() string

func (Complex128) Type

func (Complex128) Type() TagID

Type returns the TagID of the data

type Complex64

type Complex64 complex64

Complex64 is an implementation of the Data interface

func (Complex64) Copy

func (c Complex64) Copy() Data

Copy simply returns a copy the the data

func (Complex64) Equal

func (c Complex64) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (Complex64) String

func (c Complex64) String() string

func (Complex64) Type

func (Complex64) Type() TagID

Type returns the TagID of the data

type Compound

type Compound []Tag

Compound is an implementation of the Data interface

func (Compound) Copy

func (c Compound) Copy() Data

Copy simply returns a deep-copy the the data

func (Compound) Equal

func (c Compound) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (Compound) Get

func (c Compound) Get(name string) Tag

Get returns the tag for the given name

func (*Compound) Remove

func (c *Compound) Remove(name string)

Remove removes the tag corresponding to the given name

func (*Compound) Set

func (c *Compound) Set(tag Tag)

Set adds the given tag to the compound, or, if the tags name is already present, overrides the old data

func (Compound) String

func (c Compound) String() string

func (Compound) Type

func (Compound) Type() TagID

Type returns the TagID of the data

type Data

type Data interface {
	Equal(interface{}) bool
	Copy() Data
	String() string
	Type() TagID
}

Data is an interface representing the many different types that a tag can be

type Decoder

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

Decoder is a type used to decode NBT streams

func NewDecoder

func NewDecoder(r io.Reader) Decoder

NewDecoder returns a Decoder using Big Endian

func NewDecoderEndian

func NewDecoderEndian(e byteio.EndianReader) Decoder

NewDecoderEndian allows you to specify your own Endian Reader

func (Decoder) Decode

func (d Decoder) Decode() (Tag, error)

Decode will read a whole tag out of the decoding stream

type Double

type Double float64

Double is an implementation of the Data interface

func (Double) Copy

func (d Double) Copy() Data

Copy simply returns a copy the the data

func (Double) Equal

func (d Double) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (Double) String

func (d Double) String() string

func (Double) Type

func (Double) Type() TagID

Type returns the TagID of the data

type Encoder

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

Encoder is a type used to encode NBT streams

func NewEncoder

func NewEncoder(w io.Writer) Encoder

NewEncoder returns an Encoder using Big Endian

func NewEncoderEndian

func NewEncoderEndian(e byteio.EndianWriter) Encoder

NewEncoderEndian allows you to specify your own Endian Writer

func (Encoder) Encode

func (e Encoder) Encode(t Tag) error

Encode will encode a whole tag to the encoding stream

type Float

type Float float32

Float is an implementation of the Data interface

func (Float) Copy

func (f Float) Copy() Data

Copy simply returns a copy the the data

func (Float) Equal

func (f Float) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (Float) String

func (f Float) String() string

func (Float) Type

func (Float) Type() TagID

Type returns the TagID of the data

type Int

type Int int32

Int is an implementation of the Data interface

func (Int) Copy

func (i Int) Copy() Data

Copy simply returns a copy the the data

func (Int) Equal

func (i Int) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (Int) String

func (i Int) String() string

func (Int) Type

func (Int) Type() TagID

Type returns the TagID of the data

type IntArray

type IntArray []int32

IntArray is an implementation of the Data interface

func (IntArray) Copy

func (i IntArray) Copy() Data

Copy simply returns a copy the the data

func (IntArray) Equal

func (i IntArray) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (IntArray) String

func (i IntArray) String() string

func (IntArray) Type

func (IntArray) Type() TagID

Type returns the TagID of the data

type List

type List interface {
	Data
	Set(int, Data) error
	Get(int) Data
	Append(...Data) error
	Insert(int, ...Data) error
	Remove(int)
	Len() int
	TagType() TagID
}

List interface descibes the methods for the lists of different data types

func NewEmptyList

func NewEmptyList(tagType TagID) List

NewEmptyList returns a new empty List Data type, set to the type given

func NewList

func NewList(data []Data) List

NewList returns a new List Data type, or nil if the given data is not of all the same Data type

type ListBool

type ListBool []Bool

ListBool satisfies the List interface for a list of Bools

func (*ListBool) Append

func (l *ListBool) Append(d ...Data) error

Append adds data to the list

func (ListBool) Copy

func (l ListBool) Copy() Data

Copy simply returns a deep-copy the the data

func (ListBool) Equal

func (l ListBool) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (ListBool) Get

func (l ListBool) Get(i int) Data

Get returns the data at the given positon

func (*ListBool) Insert

func (l *ListBool) Insert(i int, d ...Data) error

Insert will add the given data at the specified position, moving other up

func (ListBool) Len

func (l ListBool) Len() int

Len returns the length of the list

func (*ListBool) Remove

func (l *ListBool) Remove(i int)

Remove deletes the specified position and shifts remaing data down

func (ListBool) Set

func (l ListBool) Set(i int, d Data) error

Set sets the data at the given position. It does not append

func (ListBool) String

func (l ListBool) String() string

func (ListBool) TagType

func (ListBool) TagType() TagID

TagType returns the TagID of the type of tag this list contains

func (ListBool) Type

func (ListBool) Type() TagID

Type returns the TagID of the data

type ListByte

type ListByte []Byte

ListByte satisfies the List interface for a list of Bytes

func (*ListByte) Append

func (l *ListByte) Append(d ...Data) error

Append adds data to the list

func (ListByte) Copy

func (l ListByte) Copy() Data

Copy simply returns a deep-copy the the data

func (ListByte) Equal

func (l ListByte) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (ListByte) Get

func (l ListByte) Get(i int) Data

Get returns the data at the given positon

func (*ListByte) Insert

func (l *ListByte) Insert(i int, d ...Data) error

Insert will add the given data at the specified position, moving other up

func (ListByte) Len

func (l ListByte) Len() int

Len returns the length of the list

func (*ListByte) Remove

func (l *ListByte) Remove(i int)

Remove deletes the specified position and shifts remaing data down

func (ListByte) Set

func (l ListByte) Set(i int, d Data) error

Set sets the data at the given position. It does not append

func (ListByte) String

func (l ListByte) String() string

func (ListByte) TagType

func (ListByte) TagType() TagID

TagType returns the TagID of the type of tag this list contains

func (ListByte) Type

func (ListByte) Type() TagID

Type returns the TagID of the data

type ListComplex128

type ListComplex128 []Complex128

ListComplex128 satisfies the List interface for a list of Complex128s

func (*ListComplex128) Append

func (l *ListComplex128) Append(d ...Data) error

Append adds data to the list

func (ListComplex128) Copy

func (l ListComplex128) Copy() Data

Copy simply returns a deep-copy the the data

func (ListComplex128) Equal

func (l ListComplex128) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (ListComplex128) Get

func (l ListComplex128) Get(i int) Data

Get returns the data at the given positon

func (*ListComplex128) Insert

func (l *ListComplex128) Insert(i int, d ...Data) error

Insert will add the given data at the specified position, moving other up

func (ListComplex128) Len

func (l ListComplex128) Len() int

Len returns the length of the list

func (*ListComplex128) Remove

func (l *ListComplex128) Remove(i int)

Remove deletes the specified position and shifts remaing data down

func (ListComplex128) Set

func (l ListComplex128) Set(i int, d Data) error

Set sets the data at the given position. It does not append

func (ListComplex128) String

func (l ListComplex128) String() string

func (ListComplex128) TagType

func (ListComplex128) TagType() TagID

TagType returns the TagID of the type of tag this list contains

func (ListComplex128) Type

func (ListComplex128) Type() TagID

Type returns the TagID of the data

type ListComplex64

type ListComplex64 []Complex64

ListComplex64 satisfies the List interface for a list of Complex64s

func (*ListComplex64) Append

func (l *ListComplex64) Append(d ...Data) error

Append adds data to the list

func (ListComplex64) Copy

func (l ListComplex64) Copy() Data

Copy simply returns a deep-copy the the data

func (ListComplex64) Equal

func (l ListComplex64) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (ListComplex64) Get

func (l ListComplex64) Get(i int) Data

Get returns the data at the given positon

func (*ListComplex64) Insert

func (l *ListComplex64) Insert(i int, d ...Data) error

Insert will add the given data at the specified position, moving other up

func (ListComplex64) Len

func (l ListComplex64) Len() int

Len returns the length of the list

func (*ListComplex64) Remove

func (l *ListComplex64) Remove(i int)

Remove deletes the specified position and shifts remaing data down

func (ListComplex64) Set

func (l ListComplex64) Set(i int, d Data) error

Set sets the data at the given position. It does not append

func (ListComplex64) String

func (l ListComplex64) String() string

func (ListComplex64) TagType

func (ListComplex64) TagType() TagID

TagType returns the TagID of the type of tag this list contains

func (ListComplex64) Type

func (ListComplex64) Type() TagID

Type returns the TagID of the data

type ListCompound

type ListCompound []Compound

ListCompound satisfies the List interface for a list of Compounds

func (*ListCompound) Append

func (l *ListCompound) Append(d ...Data) error

Append adds data to the list

func (ListCompound) Copy

func (l ListCompound) Copy() Data

Copy simply returns a deep-copy the the data

func (ListCompound) Equal

func (l ListCompound) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (ListCompound) Get

func (l ListCompound) Get(i int) Data

Get returns the data at the given positon

func (*ListCompound) Insert

func (l *ListCompound) Insert(i int, d ...Data) error

Insert will add the given data at the specified position, moving other up

func (ListCompound) Len

func (l ListCompound) Len() int

Len returns the length of the list

func (*ListCompound) Remove

func (l *ListCompound) Remove(i int)

Remove deletes the specified position and shifts remaing data down

func (ListCompound) Set

func (l ListCompound) Set(i int, d Data) error

Set sets the data at the given position. It does not append

func (ListCompound) String

func (l ListCompound) String() string

func (ListCompound) TagType

func (ListCompound) TagType() TagID

TagType returns the TagID of the type of tag this list contains

func (ListCompound) Type

func (ListCompound) Type() TagID

Type returns the TagID of the data

type ListData

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

ListData is an implementation of the Data interface

func (*ListData) Append

func (l *ListData) Append(data ...Data) error

Append adds data to the list

func (*ListData) Copy

func (l *ListData) Copy() Data

Copy simply returns a deep-copy the the data

func (*ListData) Equal

func (l *ListData) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (*ListData) Get

func (l *ListData) Get(i int) Data

Get returns the data at the given positon

func (*ListData) Insert

func (l *ListData) Insert(i int, data ...Data) error

Insert will add the given data at the specified position, moving other elements up.

func (*ListData) Len

func (l *ListData) Len() int

Len returns the length of the list

func (ListData) ListBool

func (l ListData) ListBool() ListBool

ListBool returns the list as a specifically typed List

func (ListData) ListByte

func (l ListData) ListByte() ListByte

ListByte returns the list as a specifically typed List

func (ListData) ListComplex128

func (l ListData) ListComplex128() ListComplex128

ListComplex128 returns the list as a specifically typed List

func (ListData) ListComplex64

func (l ListData) ListComplex64() ListComplex64

ListComplex64 returns the list as a specifically typed List

func (ListData) ListCompound

func (l ListData) ListCompound() ListCompound

ListCompound returns the list as a specifically typed List

func (ListData) ListDouble

func (l ListData) ListDouble() ListDouble

ListDouble returns the list as a specifically typed List

func (ListData) ListEnd

func (l ListData) ListEnd() ListEnd

ListEnd returns the list as a specifically typed List

func (ListData) ListFloat

func (l ListData) ListFloat() ListFloat

ListFloat returns the list as a specifically typed List

func (ListData) ListInt

func (l ListData) ListInt() ListInt

ListInt returns the list as a specifically typed List

func (ListData) ListIntArray

func (l ListData) ListIntArray() ListIntArray

ListIntArray returns the list as a specifically typed List

func (ListData) ListLong

func (l ListData) ListLong() ListLong

ListLong returns the list as a specifically typed List

func (ListData) ListShort

func (l ListData) ListShort() ListShort

ListShort returns the list as a specifically typed List

func (ListData) ListUint16

func (l ListData) ListUint16() ListUint16

ListUint16 returns the list as a specifically typed List

func (ListData) ListUint32

func (l ListData) ListUint32() ListUint32

ListUint32 returns the list as a specifically typed List

func (ListData) ListUint64

func (l ListData) ListUint64() ListUint64

ListUint64 returns the list as a specifically typed List

func (ListData) ListUint8

func (l ListData) ListUint8() ListUint8

ListUint8 returns the list as a specifically typed List

func (*ListData) Remove

func (l *ListData) Remove(i int)

Remove deletes the specified position and shifts remaing data down

func (*ListData) Set

func (l *ListData) Set(i int, data Data) error

Set sets the data at the given position. It does not append

func (*ListData) String

func (l *ListData) String() string

func (*ListData) TagType

func (l *ListData) TagType() TagID

TagType returns the TagID of the type of tag this list contains

func (ListData) Type

func (ListData) Type() TagID

Type returns the TagID of the data

type ListDouble

type ListDouble []Double

ListDouble satisfies the List interface for a list of Doubles

func (*ListDouble) Append

func (l *ListDouble) Append(d ...Data) error

Append adds data to the list

func (ListDouble) Copy

func (l ListDouble) Copy() Data

Copy simply returns a deep-copy the the data

func (ListDouble) Equal

func (l ListDouble) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (ListDouble) Get

func (l ListDouble) Get(i int) Data

Get returns the data at the given positon

func (*ListDouble) Insert

func (l *ListDouble) Insert(i int, d ...Data) error

Insert will add the given data at the specified position, moving other up

func (ListDouble) Len

func (l ListDouble) Len() int

Len returns the length of the list

func (*ListDouble) Remove

func (l *ListDouble) Remove(i int)

Remove deletes the specified position and shifts remaing data down

func (ListDouble) Set

func (l ListDouble) Set(i int, d Data) error

Set sets the data at the given position. It does not append

func (ListDouble) String

func (l ListDouble) String() string

func (ListDouble) TagType

func (ListDouble) TagType() TagID

TagType returns the TagID of the type of tag this list contains

func (ListDouble) Type

func (ListDouble) Type() TagID

Type returns the TagID of the data

type ListEnd

type ListEnd uint32

ListEnd satisfies the List interface for a list of Ends

func (*ListEnd) Append

func (l *ListEnd) Append(d ...Data) error

Append adds to the list

func (ListEnd) Copy

func (l ListEnd) Copy() Data

Copy simply returns a deep-copy the the data

func (ListEnd) Equal

func (l ListEnd) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (ListEnd) Get

func (ListEnd) Get(_ int) Data

Get returns an end{}

func (*ListEnd) Insert

func (l *ListEnd) Insert(_ int, d ...Data) error

Insert adds to the list

func (ListEnd) Len

func (l ListEnd) Len() int

Len returns the length of the List

func (*ListEnd) Remove

func (l *ListEnd) Remove(i int)

Remove removes from the list

func (ListEnd) Set

func (l ListEnd) Set(_ int, d Data) error

Set does nothing as it's not applicable for ListEnd

func (ListEnd) String

func (l ListEnd) String() string

func (ListEnd) TagType

func (ListEnd) TagType() TagID

TagType returns the TagID of the type of tag this list contains

func (ListEnd) Type

func (ListEnd) Type() TagID

Type returns the TagID of the data

type ListFloat

type ListFloat []Float

ListFloat satisfies the List interface for a list of Floats

func (*ListFloat) Append

func (l *ListFloat) Append(d ...Data) error

Append adds data to the list

func (ListFloat) Copy

func (l ListFloat) Copy() Data

Copy simply returns a deep-copy the the data

func (ListFloat) Equal

func (l ListFloat) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (ListFloat) Get

func (l ListFloat) Get(i int) Data

Get returns the data at the given positon

func (*ListFloat) Insert

func (l *ListFloat) Insert(i int, d ...Data) error

Insert will add the given data at the specified position, moving other up

func (ListFloat) Len

func (l ListFloat) Len() int

Len returns the length of the list

func (*ListFloat) Remove

func (l *ListFloat) Remove(i int)

Remove deletes the specified position and shifts remaing data down

func (ListFloat) Set

func (l ListFloat) Set(i int, d Data) error

Set sets the data at the given position. It does not append

func (ListFloat) String

func (l ListFloat) String() string

func (ListFloat) TagType

func (ListFloat) TagType() TagID

TagType returns the TagID of the type of tag this list contains

func (ListFloat) Type

func (ListFloat) Type() TagID

Type returns the TagID of the data

type ListInt

type ListInt []Int

ListInt satisfies the List interface for a list of Ints

func (*ListInt) Append

func (l *ListInt) Append(d ...Data) error

Append adds data to the list

func (ListInt) Copy

func (l ListInt) Copy() Data

Copy simply returns a deep-copy the the data

func (ListInt) Equal

func (l ListInt) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (ListInt) Get

func (l ListInt) Get(i int) Data

Get returns the data at the given positon

func (*ListInt) Insert

func (l *ListInt) Insert(i int, d ...Data) error

Insert will add the given data at the specified position, moving other up

func (ListInt) Len

func (l ListInt) Len() int

Len returns the length of the list

func (*ListInt) Remove

func (l *ListInt) Remove(i int)

Remove deletes the specified position and shifts remaing data down

func (ListInt) Set

func (l ListInt) Set(i int, d Data) error

Set sets the data at the given position. It does not append

func (ListInt) String

func (l ListInt) String() string

func (ListInt) TagType

func (ListInt) TagType() TagID

TagType returns the TagID of the type of tag this list contains

func (ListInt) Type

func (ListInt) Type() TagID

Type returns the TagID of the data

type ListIntArray

type ListIntArray []IntArray

ListIntArray satisfies the List interface for a list of IntArrays

func (*ListIntArray) Append

func (l *ListIntArray) Append(d ...Data) error

Append adds data to the list

func (ListIntArray) Copy

func (l ListIntArray) Copy() Data

Copy simply returns a deep-copy the the data

func (ListIntArray) Equal

func (l ListIntArray) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (ListIntArray) Get

func (l ListIntArray) Get(i int) Data

Get returns the data at the given positon

func (*ListIntArray) Insert

func (l *ListIntArray) Insert(i int, d ...Data) error

Insert will add the given data at the specified position, moving other up

func (ListIntArray) Len

func (l ListIntArray) Len() int

Len returns the length of the list

func (*ListIntArray) Remove

func (l *ListIntArray) Remove(i int)

Remove deletes the specified position and shifts remaing data down

func (ListIntArray) Set

func (l ListIntArray) Set(i int, d Data) error

Set sets the data at the given position. It does not append

func (ListIntArray) String

func (l ListIntArray) String() string

func (ListIntArray) TagType

func (ListIntArray) TagType() TagID

TagType returns the TagID of the type of tag this list contains

func (ListIntArray) Type

func (ListIntArray) Type() TagID

Type returns the TagID of the data

type ListLong

type ListLong []Long

ListLong satisfies the List interface for a list of Longs

func (*ListLong) Append

func (l *ListLong) Append(d ...Data) error

Append adds data to the list

func (ListLong) Copy

func (l ListLong) Copy() Data

Copy simply returns a deep-copy the the data

func (ListLong) Equal

func (l ListLong) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (ListLong) Get

func (l ListLong) Get(i int) Data

Get returns the data at the given positon

func (*ListLong) Insert

func (l *ListLong) Insert(i int, d ...Data) error

Insert will add the given data at the specified position, moving other up

func (ListLong) Len

func (l ListLong) Len() int

Len returns the length of the list

func (*ListLong) Remove

func (l *ListLong) Remove(i int)

Remove deletes the specified position and shifts remaing data down

func (ListLong) Set

func (l ListLong) Set(i int, d Data) error

Set sets the data at the given position. It does not append

func (ListLong) String

func (l ListLong) String() string

func (ListLong) TagType

func (ListLong) TagType() TagID

TagType returns the TagID of the type of tag this list contains

func (ListLong) Type

func (ListLong) Type() TagID

Type returns the TagID of the data

type ListShort

type ListShort []Short

ListShort satisfies the List interface for a list of Shorts

func (*ListShort) Append

func (l *ListShort) Append(d ...Data) error

Append adds data to the list

func (ListShort) Copy

func (l ListShort) Copy() Data

Copy simply returns a deep-copy the the data

func (ListShort) Equal

func (l ListShort) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (ListShort) Get

func (l ListShort) Get(i int) Data

Get returns the data at the given positon

func (*ListShort) Insert

func (l *ListShort) Insert(i int, d ...Data) error

Insert will add the given data at the specified position, moving other up

func (ListShort) Len

func (l ListShort) Len() int

Len returns the length of the list

func (*ListShort) Remove

func (l *ListShort) Remove(i int)

Remove deletes the specified position and shifts remaing data down

func (ListShort) Set

func (l ListShort) Set(i int, d Data) error

Set sets the data at the given position. It does not append

func (ListShort) String

func (l ListShort) String() string

func (ListShort) TagType

func (ListShort) TagType() TagID

TagType returns the TagID of the type of tag this list contains

func (ListShort) Type

func (ListShort) Type() TagID

Type returns the TagID of the data

type ListUint16

type ListUint16 []Uint16

ListUint16 satisfies the List interface for a list of Uint16s

func (*ListUint16) Append

func (l *ListUint16) Append(d ...Data) error

Append adds data to the list

func (ListUint16) Copy

func (l ListUint16) Copy() Data

Copy simply returns a deep-copy the the data

func (ListUint16) Equal

func (l ListUint16) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (ListUint16) Get

func (l ListUint16) Get(i int) Data

Get returns the data at the given positon

func (*ListUint16) Insert

func (l *ListUint16) Insert(i int, d ...Data) error

Insert will add the given data at the specified position, moving other up

func (ListUint16) Len

func (l ListUint16) Len() int

Len returns the length of the list

func (*ListUint16) Remove

func (l *ListUint16) Remove(i int)

Remove deletes the specified position and shifts remaing data down

func (ListUint16) Set

func (l ListUint16) Set(i int, d Data) error

Set sets the data at the given position. It does not append

func (ListUint16) String

func (l ListUint16) String() string

func (ListUint16) TagType

func (ListUint16) TagType() TagID

TagType returns the TagID of the type of tag this list contains

func (ListUint16) Type

func (ListUint16) Type() TagID

Type returns the TagID of the data

type ListUint32

type ListUint32 []Uint32

ListUint32 satisfies the List interface for a list of Uint32s

func (*ListUint32) Append

func (l *ListUint32) Append(d ...Data) error

Append adds data to the list

func (ListUint32) Copy

func (l ListUint32) Copy() Data

Copy simply returns a deep-copy the the data

func (ListUint32) Equal

func (l ListUint32) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (ListUint32) Get

func (l ListUint32) Get(i int) Data

Get returns the data at the given positon

func (*ListUint32) Insert

func (l *ListUint32) Insert(i int, d ...Data) error

Insert will add the given data at the specified position, moving other up

func (ListUint32) Len

func (l ListUint32) Len() int

Len returns the length of the list

func (*ListUint32) Remove

func (l *ListUint32) Remove(i int)

Remove deletes the specified position and shifts remaing data down

func (ListUint32) Set

func (l ListUint32) Set(i int, d Data) error

Set sets the data at the given position. It does not append

func (ListUint32) String

func (l ListUint32) String() string

func (ListUint32) TagType

func (ListUint32) TagType() TagID

TagType returns the TagID of the type of tag this list contains

func (ListUint32) Type

func (ListUint32) Type() TagID

Type returns the TagID of the data

type ListUint64

type ListUint64 []Uint64

ListUint64 satisfies the List interface for a list of Uint64s

func (*ListUint64) Append

func (l *ListUint64) Append(d ...Data) error

Append adds data to the list

func (ListUint64) Copy

func (l ListUint64) Copy() Data

Copy simply returns a deep-copy the the data

func (ListUint64) Equal

func (l ListUint64) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (ListUint64) Get

func (l ListUint64) Get(i int) Data

Get returns the data at the given positon

func (*ListUint64) Insert

func (l *ListUint64) Insert(i int, d ...Data) error

Insert will add the given data at the specified position, moving other up

func (ListUint64) Len

func (l ListUint64) Len() int

Len returns the length of the list

func (*ListUint64) Remove

func (l *ListUint64) Remove(i int)

Remove deletes the specified position and shifts remaing data down

func (ListUint64) Set

func (l ListUint64) Set(i int, d Data) error

Set sets the data at the given position. It does not append

func (ListUint64) String

func (l ListUint64) String() string

func (ListUint64) TagType

func (ListUint64) TagType() TagID

TagType returns the TagID of the type of tag this list contains

func (ListUint64) Type

func (ListUint64) Type() TagID

Type returns the TagID of the data

type ListUint8

type ListUint8 []Uint8

ListUint8 satisfies the List interface for a list of Uint8s

func (*ListUint8) Append

func (l *ListUint8) Append(d ...Data) error

Append adds data to the list

func (ListUint8) Copy

func (l ListUint8) Copy() Data

Copy simply returns a deep-copy the the data

func (ListUint8) Equal

func (l ListUint8) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (ListUint8) Get

func (l ListUint8) Get(i int) Data

Get returns the data at the given positon

func (*ListUint8) Insert

func (l *ListUint8) Insert(i int, d ...Data) error

Insert will add the given data at the specified position, moving other up

func (ListUint8) Len

func (l ListUint8) Len() int

Len returns the length of the list

func (*ListUint8) Remove

func (l *ListUint8) Remove(i int)

Remove deletes the specified position and shifts remaing data down

func (ListUint8) Set

func (l ListUint8) Set(i int, d Data) error

Set sets the data at the given position. It does not append

func (ListUint8) String

func (l ListUint8) String() string

func (ListUint8) TagType

func (ListUint8) TagType() TagID

TagType returns the TagID of the type of tag this list contains

func (ListUint8) Type

func (ListUint8) Type() TagID

Type returns the TagID of the data

type Long

type Long int64

Long is an implementation of the Data interface

func (Long) Copy

func (l Long) Copy() Data

Copy simply returns a copy the the data

func (Long) Equal

func (l Long) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (Long) String

func (l Long) String() string

func (Long) Type

func (Long) Type() TagID

Type returns the TagID of the data

type ReadError

type ReadError struct {
	Where string
	Err   error
}

ReadError is an error returned when a read error occurs

func (ReadError) Error

func (r ReadError) Error() string

type Short

type Short int16

Short is an implementation of the Data interface

func (Short) Copy

func (s Short) Copy() Data

Copy simply returns a copy the the data

func (Short) Equal

func (s Short) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (Short) String

func (s Short) String() string

func (Short) Type

func (Short) Type() TagID

Type returns the TagID of the data

type String

type String string

String is an implementation of the Data interface

func (String) Copy

func (s String) Copy() Data

Copy simply returns a copy the the data

func (String) Equal

func (s String) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (String) String

func (s String) String() string

func (String) Type

func (String) Type() TagID

Type returns the TagID of the data

type Tag

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

Tag is the main NBT type, a combination of a name and a Data type

func Decode

func Decode(r io.Reader) (Tag, error)

Decode will eencode a single tag from the reader using the default settings

func NewTag

func NewTag(name string, d Data) Tag

NewTag constructs a new tag with the given name and data.

func (Tag) Copy

func (t Tag) Copy() Tag

Copy simply returns a deep-copy the the tag

func (Tag) Data

func (t Tag) Data() Data

Data returns the tags data type

func (Tag) Equal

func (t Tag) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (Tag) Name

func (t Tag) Name() string

Name returns the tags' name

func (Tag) String

func (t Tag) String() string

String returns a textual representation of the tag

func (Tag) TagID

func (t Tag) TagID() TagID

TagID returns the type of the data

type TagID

type TagID uint8

TagID represents the type of nbt tag

const (
	TagEnd        TagID = 0
	TagByte       TagID = 1
	TagShort      TagID = 2
	TagInt        TagID = 3
	TagLong       TagID = 4
	TagFloat      TagID = 5
	TagDouble     TagID = 6
	TagByteArray  TagID = 7
	TagString     TagID = 8
	TagList       TagID = 9
	TagCompound   TagID = 10
	TagIntArray   TagID = 11
	TagBool       TagID = 12
	TagUint8      TagID = 13
	TagUint16     TagID = 14
	TagUint32     TagID = 15
	TagUint64     TagID = 16
	TagComplex64  TagID = 17
	TagComplex128 TagID = 18
)

Tag Types

func (TagID) String

func (t TagID) String() string

type Uint16

type Uint16 uint16

Uint16 is an implementation of the Data interface

func (Uint16) Copy

func (u Uint16) Copy() Data

Copy simply returns a copy the the data

func (Uint16) Equal

func (u Uint16) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (Uint16) String

func (u Uint16) String() string

func (Uint16) Type

func (Uint16) Type() TagID

Type returns the TagID of the data

type Uint32

type Uint32 uint32

Uint32 is an implementation of the Data interface

func (Uint32) Copy

func (u Uint32) Copy() Data

Copy simply returns a copy the the data

func (Uint32) Equal

func (u Uint32) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (Uint32) String

func (u Uint32) String() string

func (Uint32) Type

func (Uint32) Type() TagID

Type returns the TagID of the data

type Uint64

type Uint64 uint64

Uint64 is an implementation of the Data interface

func (Uint64) Copy

func (u Uint64) Copy() Data

Copy simply returns a copy the the data

func (Uint64) Equal

func (u Uint64) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (Uint64) String

func (u Uint64) String() string

func (Uint64) Type

func (Uint64) Type() TagID

Type returns the TagID of the data

type Uint8

type Uint8 uint8

Uint8 is an implementation of the Data interface

func (Uint8) Copy

func (u Uint8) Copy() Data

Copy simply returns a copy the the data

func (Uint8) Equal

func (u Uint8) Equal(e interface{}) bool

Equal satisfies the equaler.Equaler interface, allowing for types to be checked for equality

func (Uint8) String

func (u Uint8) String() string

func (Uint8) Type

func (Uint8) Type() TagID

Type returns the TagID of the data

type UnknownTag

type UnknownTag struct {
	TagID
}

UnknownTag is an error that occurs when an unknown tag id is discovered. This could also indicate corrupted or non-compliant data.

func (UnknownTag) Error

func (u UnknownTag) Error() string

type WriteError

type WriteError struct {
	Where string
	Err   error
}

WriteError is an error returned when a write error occurs

func (WriteError) Error

func (w WriteError) Error() string

type WrongTag

type WrongTag struct {
	Expecting, Got TagID
}

WrongTag is an error returned when a tag of the incorrect type was intended to be added to a list.

func (WrongTag) Error

func (w WrongTag) Error() string

Jump to

Keyboard shortcuts

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