44 lines
594 B
Go
44 lines
594 B
Go
// Package nbt implement the Named Binary Tag format of Minecraft.
|
|
// It provides api like encoding/xml package.
|
|
package nbt
|
|
|
|
import (
|
|
"bufio"
|
|
"io"
|
|
)
|
|
|
|
//Tag type IDs
|
|
const (
|
|
TagEnd byte = iota
|
|
TagByte
|
|
TagShort
|
|
TagInt
|
|
TagLong
|
|
TagFloat
|
|
TagDouble
|
|
TagByteArray
|
|
TagString
|
|
TagList
|
|
TagCompound
|
|
TagIntArray
|
|
TagLongArray
|
|
)
|
|
|
|
type DecoderReader = interface {
|
|
io.ByteScanner
|
|
io.Reader
|
|
}
|
|
type Decoder struct {
|
|
r DecoderReader
|
|
}
|
|
|
|
func NewDecoder(r io.Reader) *Decoder {
|
|
d := new(Decoder)
|
|
if br, ok := r.(DecoderReader); ok {
|
|
d.r = br
|
|
} else {
|
|
d.r = bufio.NewReader(r)
|
|
}
|
|
return d
|
|
}
|