Documentation ¶
Overview ¶
Example ¶
package main import ( "fmt" "io/ioutil" "os" "github.com/ymohl-cl/gonbt" ) const ( exampleFilesPath = "./example" ) func main() { var err error var files []os.FileInfo if files, err = ioutil.ReadDir(exampleFilesPath); err != nil { panic(err) } for _, file := range files { if file.IsDir() { continue } var dataIn []byte var tag gonbt.Tag if dataIn, err = ioutil.ReadFile(exampleFilesPath + "/" + file.Name()); err != nil { panic(err) } if tag, err = gonbt.Unmarshal(dataIn); err != nil { panic(err) } if _, err = gonbt.Marshal(tag, gonbt.CompressGZIP); err != nil { panic(err) } if _, err = gonbt.Marshal(tag, gonbt.CompressNone); err != nil { panic(err) } fmt.Printf("%s ok\n", file.Name()) } }
Output: servers.dat ok level.dat ok
Index ¶
Examples ¶
Constants ¶
const ( CompressGZIP = "gzip" CompressZLIB = "zlib" CompressNone = "none" )
constant compression type
const ( TagEnd byte = iota TagByte TagShort TagInt TagLong TagFloat TagDouble TagByteArray TagString TagList TagCompound TagIntArray TagLongArray )
TagType values
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ByteArrayT ¶
ByteArrayT to byte array type: 7
func (*ByteArrayT) Read ¶
func (t *ByteArrayT) Read(reader Reader) error
7 TAG_Byte_Array TAG_Int's payload size, then size TAG_Byte's payloads. [B;<byte>,<byte>,...] An array of bytes. Maximum number of elements ranges between (231 - 9) and (231 - 1) (2,147,483,639 and 2,147,483,647), depending on the specific JVM.
type ByteT ¶
ByteT to byte type: 1
type CompoundT ¶
CompoundT to compound type: 10
func (*CompoundT) Read ¶
10 TAG_Compound Fully formed tags, followed by a TAG_End. {<tag name>:<value>,<tag name>:<value>,...} A list of fully formed tags, including their IDs, names, and payloads. No two tags may have the same name. Unlike lists, there is no hard limit to the number of tags within a Compound (of course, there is always the implicit limit of virtual memory). Note, however, that Compound and List tags may not be nested beyond a depth of 512.
type DoubleT ¶
DoubleT to double type: 6
type FloatT ¶
FloatT to float type: 5
type IntArrayT ¶
IntArrayT to int array type: 11
type IntT ¶
IntT to int type: 3
type ListT ¶
type ListT struct { Name string Value []interface{} }
ListT to list type: 9
func (*ListT) Read ¶
9 TAG_List TAG_Byte's payload tagId, then TAG_Int's payload size, then size tags' payloads, all of type tagId. [<value>,<value>,...] A list of tag payloads, without repeated tag IDs or any tag names. Due to JVM limitations and the implementation of ArrayList, the maximum number of list elements is (231 - 9), or 2,147,483,639. Also note that List and Compound tags may not be nested beyond a depth of 512.
type LongArrayT ¶
LongArrayT to long array type: 12
type LongT ¶
LongT to long type: 4
type Reader ¶
type Reader interface { String() (string, error) Byte() (byte, error) Short() (int16, error) Int() (int32, error) Long() (int64, error) Float() (float32, error) Double() (float64, error) Bytes() ([]byte, error) IntArray() ([]int32, error) LongArray() ([]int64, error) }
Reader nbt
type ShortT ¶
ShortT to short type: 2
type StringT ¶
StringT to string type: 8
func (*StringT) Read ¶
8 TAG_String A TAG_Short-like, but instead unsigned[2] payload length, then a UTF-8 string resembled by length bytes. <a-zA-Z0-9 text>, "<text>" (" within needs to be escaped to \"), or '<text>' (' within needs to be escaped to \') A UTF-8 string. It has a size, rather than being null terminated. 65,535 bytes interpretable as UTF-8 (see modified UTF-8 format; most commonly-used characters are a single byte).