Documentation ¶
Index ¶
- Variables
- func CompactJson(tag Tag) string
- func CompactStringify(tag Tag) string
- func Encode(w io.Writer, tag Tag) error
- func Json(tag Tag) string
- func PrettyJson(tag Tag, indent string) string
- func PrettyStringify(tag Tag, indent string) string
- func SetLogger(l liblog.Logger)
- func Stringify(tag Tag) string
- type ByteArrayPayload
- type ByteArrayTag
- type BytePayload
- type ByteTag
- type CompoundPayload
- type CompoundTag
- type DoublePayload
- type DoubleTag
- type EndTag
- type FloatPayload
- type FloatTag
- type IntArrayPayload
- type IntArrayTag
- type IntPayload
- type IntTag
- type ListPayload
- type ListTag
- type LongArrayPayload
- type LongArrayTag
- type LongPayload
- type LongTag
- type NbtError
- type Payload
- type ShortPayload
- type ShortTag
- type StringPayload
- type StringTag
- type Tag
- type TagName
- type TagType
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidTagType = errors.New("invalid tag type") ErrInvalidSnbtFormat = errors.New("invalid snbt format") ErrDecode = errors.New("failed to decode") )
View Source
var TagTypes []TagType = []TagType{ TagTypeEnd, TagTypeByte, TagTypeShort, TagTypeInt, TagTypeLong, TagTypeFloat, TagTypeDouble, TagTypeByteArray, TagTypeString, TagTypeList, TagTypeCompound, TagTypeIntArray, TagTypeLongArray, }
Functions ¶
func CompactJson ¶
Example ¶
package main import ( "fmt" nbt "github.com/Aton-Kish/gonbt" ) func main() { dat := nbt.NewCompoundTag(nbt.NewTagName("Data"), nbt.NewCompoundPayload( nbt.NewIntTag(nbt.NewTagName("GameType"), nbt.NewIntPayload(0)), nbt.NewStringTag(nbt.NewTagName("LevelName"), nbt.NewStringPayload("Go NBT")), nbt.NewCompoundTag(nbt.NewTagName("Version"), nbt.NewCompoundPayload( nbt.NewIntTag(nbt.NewTagName("Id"), nbt.NewIntPayload(3120)), nbt.NewStringTag(nbt.NewTagName("Name"), nbt.NewStringPayload("1.19.2")), nbt.NewStringTag(nbt.NewTagName("Series"), nbt.NewStringPayload("main")), nbt.NewByteTag(nbt.NewTagName("Snapshot"), nbt.NewBytePayload(0)), nbt.NewEndTag(), )), nbt.NewEndTag(), )) fmt.Println(nbt.CompactJson(dat)) }
Output: {"Data":{"GameType":0,"LevelName":"Go NBT","Version":{"Id":3120,"Name":"1.19.2","Series":"main","Snapshot":0}}}
func CompactStringify ¶
Example ¶
package main import ( "fmt" nbt "github.com/Aton-Kish/gonbt" ) func main() { dat := nbt.NewCompoundTag(nbt.NewTagName("Data"), nbt.NewCompoundPayload( nbt.NewIntTag(nbt.NewTagName("GameType"), nbt.NewIntPayload(0)), nbt.NewStringTag(nbt.NewTagName("LevelName"), nbt.NewStringPayload("Go NBT")), nbt.NewCompoundTag(nbt.NewTagName("Version"), nbt.NewCompoundPayload( nbt.NewIntTag(nbt.NewTagName("Id"), nbt.NewIntPayload(3120)), nbt.NewStringTag(nbt.NewTagName("Name"), nbt.NewStringPayload("1.19.2")), nbt.NewStringTag(nbt.NewTagName("Series"), nbt.NewStringPayload("main")), nbt.NewByteTag(nbt.NewTagName("Snapshot"), nbt.NewBytePayload(0)), nbt.NewEndTag(), )), nbt.NewEndTag(), )) fmt.Println(nbt.CompactStringify(dat)) }
Output: {Data:{GameType:0,LevelName:"Go NBT",Version:{Id:3120,Name:"1.19.2",Series:"main",Snapshot:0b}}}
func Encode ¶
Example ¶
package main import ( "bytes" "log" nbt "github.com/Aton-Kish/gonbt" ) func main() { dat := nbt.NewCompoundTag(nbt.NewTagName("Data"), nbt.NewCompoundPayload( nbt.NewIntTag(nbt.NewTagName("GameType"), nbt.NewIntPayload(0)), nbt.NewStringTag(nbt.NewTagName("LevelName"), nbt.NewStringPayload("Go NBT")), nbt.NewCompoundTag(nbt.NewTagName("Version"), nbt.NewCompoundPayload( nbt.NewIntTag(nbt.NewTagName("Id"), nbt.NewIntPayload(3120)), nbt.NewStringTag(nbt.NewTagName("Name"), nbt.NewStringPayload("1.19.2")), nbt.NewStringTag(nbt.NewTagName("Series"), nbt.NewStringPayload("main")), nbt.NewByteTag(nbt.NewTagName("Snapshot"), nbt.NewBytePayload(0)), nbt.NewEndTag(), )), nbt.NewEndTag(), )) buf := new(bytes.Buffer) if err := nbt.Encode(buf, dat); err != nil { log.Fatal(err) } // f, err := os.Create("level.dat") // if err != nil { // log.Fatal(err) // } // defer f.Close() // zw := gzip.NewWriter(f) // defer zw.Close() // if _, err := zw.Write(buf.Bytes()); err != nil { // log.Fatal(err) // } }
Output:
func Json ¶
Example ¶
package main import ( "fmt" nbt "github.com/Aton-Kish/gonbt" ) func main() { dat := nbt.NewCompoundTag(nbt.NewTagName("Data"), nbt.NewCompoundPayload( nbt.NewIntTag(nbt.NewTagName("GameType"), nbt.NewIntPayload(0)), nbt.NewStringTag(nbt.NewTagName("LevelName"), nbt.NewStringPayload("Go NBT")), nbt.NewCompoundTag(nbt.NewTagName("Version"), nbt.NewCompoundPayload( nbt.NewIntTag(nbt.NewTagName("Id"), nbt.NewIntPayload(3120)), nbt.NewStringTag(nbt.NewTagName("Name"), nbt.NewStringPayload("1.19.2")), nbt.NewStringTag(nbt.NewTagName("Series"), nbt.NewStringPayload("main")), nbt.NewByteTag(nbt.NewTagName("Snapshot"), nbt.NewBytePayload(0)), nbt.NewEndTag(), )), nbt.NewEndTag(), )) fmt.Println(nbt.Json(dat)) }
Output: {"Data": {"GameType": 0, "LevelName": "Go NBT", "Version": {"Id": 3120, "Name": "1.19.2", "Series": "main", "Snapshot": 0}}}
func PrettyJson ¶
Example (Space2) ¶
package main import ( "fmt" nbt "github.com/Aton-Kish/gonbt" ) func main() { dat := nbt.NewCompoundTag(nbt.NewTagName("Data"), nbt.NewCompoundPayload( nbt.NewIntTag(nbt.NewTagName("GameType"), nbt.NewIntPayload(0)), nbt.NewStringTag(nbt.NewTagName("LevelName"), nbt.NewStringPayload("Go NBT")), nbt.NewCompoundTag(nbt.NewTagName("Version"), nbt.NewCompoundPayload( nbt.NewIntTag(nbt.NewTagName("Id"), nbt.NewIntPayload(3120)), nbt.NewStringTag(nbt.NewTagName("Name"), nbt.NewStringPayload("1.19.2")), nbt.NewStringTag(nbt.NewTagName("Series"), nbt.NewStringPayload("main")), nbt.NewByteTag(nbt.NewTagName("Snapshot"), nbt.NewBytePayload(0)), nbt.NewEndTag(), )), nbt.NewEndTag(), )) fmt.Println(nbt.PrettyJson(dat, " ")) }
Output: { "Data": { "GameType": 0, "LevelName": "Go NBT", "Version": { "Id": 3120, "Name": "1.19.2", "Series": "main", "Snapshot": 0 } } }
Example (Space4) ¶
package main import ( "fmt" nbt "github.com/Aton-Kish/gonbt" ) func main() { dat := nbt.NewCompoundTag(nbt.NewTagName("Data"), nbt.NewCompoundPayload( nbt.NewIntTag(nbt.NewTagName("GameType"), nbt.NewIntPayload(0)), nbt.NewStringTag(nbt.NewTagName("LevelName"), nbt.NewStringPayload("Go NBT")), nbt.NewCompoundTag(nbt.NewTagName("Version"), nbt.NewCompoundPayload( nbt.NewIntTag(nbt.NewTagName("Id"), nbt.NewIntPayload(3120)), nbt.NewStringTag(nbt.NewTagName("Name"), nbt.NewStringPayload("1.19.2")), nbt.NewStringTag(nbt.NewTagName("Series"), nbt.NewStringPayload("main")), nbt.NewByteTag(nbt.NewTagName("Snapshot"), nbt.NewBytePayload(0)), nbt.NewEndTag(), )), nbt.NewEndTag(), )) fmt.Println(nbt.PrettyJson(dat, " ")) }
Output: { "Data": { "GameType": 0, "LevelName": "Go NBT", "Version": { "Id": 3120, "Name": "1.19.2", "Series": "main", "Snapshot": 0 } } }
Example (Tab) ¶
package main import ( "fmt" nbt "github.com/Aton-Kish/gonbt" ) func main() { dat := nbt.NewCompoundTag(nbt.NewTagName("Data"), nbt.NewCompoundPayload( nbt.NewIntTag(nbt.NewTagName("GameType"), nbt.NewIntPayload(0)), nbt.NewStringTag(nbt.NewTagName("LevelName"), nbt.NewStringPayload("Go NBT")), nbt.NewCompoundTag(nbt.NewTagName("Version"), nbt.NewCompoundPayload( nbt.NewIntTag(nbt.NewTagName("Id"), nbt.NewIntPayload(3120)), nbt.NewStringTag(nbt.NewTagName("Name"), nbt.NewStringPayload("1.19.2")), nbt.NewStringTag(nbt.NewTagName("Series"), nbt.NewStringPayload("main")), nbt.NewByteTag(nbt.NewTagName("Snapshot"), nbt.NewBytePayload(0)), nbt.NewEndTag(), )), nbt.NewEndTag(), )) fmt.Println(nbt.PrettyJson(dat, "\t")) }
Output: { "Data": { "GameType": 0, "LevelName": "Go NBT", "Version": { "Id": 3120, "Name": "1.19.2", "Series": "main", "Snapshot": 0 } } }
func PrettyStringify ¶
Example (Space2) ¶
package main import ( "fmt" nbt "github.com/Aton-Kish/gonbt" ) func main() { dat := nbt.NewCompoundTag(nbt.NewTagName("Data"), nbt.NewCompoundPayload( nbt.NewIntTag(nbt.NewTagName("GameType"), nbt.NewIntPayload(0)), nbt.NewStringTag(nbt.NewTagName("LevelName"), nbt.NewStringPayload("Go NBT")), nbt.NewCompoundTag(nbt.NewTagName("Version"), nbt.NewCompoundPayload( nbt.NewIntTag(nbt.NewTagName("Id"), nbt.NewIntPayload(3120)), nbt.NewStringTag(nbt.NewTagName("Name"), nbt.NewStringPayload("1.19.2")), nbt.NewStringTag(nbt.NewTagName("Series"), nbt.NewStringPayload("main")), nbt.NewByteTag(nbt.NewTagName("Snapshot"), nbt.NewBytePayload(0)), nbt.NewEndTag(), )), nbt.NewEndTag(), )) fmt.Println(nbt.PrettyStringify(dat, " ")) }
Output: { Data: { GameType: 0, LevelName: "Go NBT", Version: { Id: 3120, Name: "1.19.2", Series: "main", Snapshot: 0b } } }
Example (Space4) ¶
package main import ( "fmt" nbt "github.com/Aton-Kish/gonbt" ) func main() { dat := nbt.NewCompoundTag(nbt.NewTagName("Data"), nbt.NewCompoundPayload( nbt.NewIntTag(nbt.NewTagName("GameType"), nbt.NewIntPayload(0)), nbt.NewStringTag(nbt.NewTagName("LevelName"), nbt.NewStringPayload("Go NBT")), nbt.NewCompoundTag(nbt.NewTagName("Version"), nbt.NewCompoundPayload( nbt.NewIntTag(nbt.NewTagName("Id"), nbt.NewIntPayload(3120)), nbt.NewStringTag(nbt.NewTagName("Name"), nbt.NewStringPayload("1.19.2")), nbt.NewStringTag(nbt.NewTagName("Series"), nbt.NewStringPayload("main")), nbt.NewByteTag(nbt.NewTagName("Snapshot"), nbt.NewBytePayload(0)), nbt.NewEndTag(), )), nbt.NewEndTag(), )) fmt.Println(nbt.PrettyStringify(dat, " ")) }
Output: { Data: { GameType: 0, LevelName: "Go NBT", Version: { Id: 3120, Name: "1.19.2", Series: "main", Snapshot: 0b } } }
Example (Tab) ¶
package main import ( "fmt" nbt "github.com/Aton-Kish/gonbt" ) func main() { dat := nbt.NewCompoundTag(nbt.NewTagName("Data"), nbt.NewCompoundPayload( nbt.NewIntTag(nbt.NewTagName("GameType"), nbt.NewIntPayload(0)), nbt.NewStringTag(nbt.NewTagName("LevelName"), nbt.NewStringPayload("Go NBT")), nbt.NewCompoundTag(nbt.NewTagName("Version"), nbt.NewCompoundPayload( nbt.NewIntTag(nbt.NewTagName("Id"), nbt.NewIntPayload(3120)), nbt.NewStringTag(nbt.NewTagName("Name"), nbt.NewStringPayload("1.19.2")), nbt.NewStringTag(nbt.NewTagName("Series"), nbt.NewStringPayload("main")), nbt.NewByteTag(nbt.NewTagName("Snapshot"), nbt.NewBytePayload(0)), nbt.NewEndTag(), )), nbt.NewEndTag(), )) fmt.Println(nbt.PrettyStringify(dat, "\t")) }
Output: { Data: { GameType: 0, LevelName: "Go NBT", Version: { Id: 3120, Name: "1.19.2", Series: "main", Snapshot: 0b } } }
func Stringify ¶
Example ¶
package main import ( "fmt" nbt "github.com/Aton-Kish/gonbt" ) func main() { dat := nbt.NewCompoundTag(nbt.NewTagName("Data"), nbt.NewCompoundPayload( nbt.NewIntTag(nbt.NewTagName("GameType"), nbt.NewIntPayload(0)), nbt.NewStringTag(nbt.NewTagName("LevelName"), nbt.NewStringPayload("Go NBT")), nbt.NewCompoundTag(nbt.NewTagName("Version"), nbt.NewCompoundPayload( nbt.NewIntTag(nbt.NewTagName("Id"), nbt.NewIntPayload(3120)), nbt.NewStringTag(nbt.NewTagName("Name"), nbt.NewStringPayload("1.19.2")), nbt.NewStringTag(nbt.NewTagName("Series"), nbt.NewStringPayload("main")), nbt.NewByteTag(nbt.NewTagName("Snapshot"), nbt.NewBytePayload(0)), nbt.NewEndTag(), )), nbt.NewEndTag(), )) fmt.Println(nbt.Stringify(dat)) }
Output: {Data: {GameType: 0, LevelName: "Go NBT", Version: {Id: 3120, Name: "1.19.2", Series: "main", Snapshot: 0b}}}
Types ¶
type ByteArrayPayload ¶
type ByteArrayPayload []int8
func NewByteArrayPayload ¶ added in v0.1.0
func NewByteArrayPayload(values ...int8) *ByteArrayPayload
func (ByteArrayPayload) String ¶ added in v0.2.0
func (p ByteArrayPayload) String() string
func (*ByteArrayPayload) TypeId ¶
func (p *ByteArrayPayload) TypeId() TagType
type ByteArrayTag ¶
type ByteArrayTag struct {
// contains filtered or unexported fields
}
func NewByteArrayTag ¶ added in v0.1.0
func NewByteArrayTag(tagName *TagName, payload *ByteArrayPayload) *ByteArrayTag
func (*ByteArrayTag) Payload ¶ added in v0.1.0
func (t *ByteArrayTag) Payload() Payload
func (ByteArrayTag) String ¶ added in v0.2.0
func (t ByteArrayTag) String() string
func (*ByteArrayTag) TagName ¶ added in v0.1.0
func (t *ByteArrayTag) TagName() *TagName
func (*ByteArrayTag) TypeId ¶
func (t *ByteArrayTag) TypeId() TagType
type BytePayload ¶
type BytePayload int8
func NewBytePayload ¶ added in v0.1.0
func NewBytePayload(value int8) *BytePayload
func (BytePayload) String ¶ added in v0.2.0
func (p BytePayload) String() string
func (*BytePayload) TypeId ¶
func (p *BytePayload) TypeId() TagType
type ByteTag ¶
type ByteTag struct {
// contains filtered or unexported fields
}
func NewByteTag ¶ added in v0.1.0
func NewByteTag(tagName *TagName, payload *BytePayload) *ByteTag
type CompoundPayload ¶
type CompoundPayload []Tag
func NewCompoundPayload ¶ added in v0.1.0
func NewCompoundPayload(values ...Tag) *CompoundPayload
func (CompoundPayload) String ¶ added in v0.2.0
func (p CompoundPayload) String() string
func (*CompoundPayload) TypeId ¶
func (p *CompoundPayload) TypeId() TagType
type CompoundTag ¶
type CompoundTag struct {
// contains filtered or unexported fields
}
func NewCompoundTag ¶ added in v0.1.0
func NewCompoundTag(tagName *TagName, payload *CompoundPayload) *CompoundTag
func (*CompoundTag) Payload ¶ added in v0.1.0
func (t *CompoundTag) Payload() Payload
func (CompoundTag) String ¶ added in v0.2.0
func (t CompoundTag) String() string
func (*CompoundTag) TagName ¶ added in v0.1.0
func (t *CompoundTag) TagName() *TagName
func (*CompoundTag) TypeId ¶
func (t *CompoundTag) TypeId() TagType
type DoublePayload ¶
type DoublePayload float64
func NewDoublePayload ¶ added in v0.1.0
func NewDoublePayload(value float64) *DoublePayload
func (DoublePayload) String ¶ added in v0.2.0
func (p DoublePayload) String() string
func (*DoublePayload) TypeId ¶
func (p *DoublePayload) TypeId() TagType
type DoubleTag ¶
type DoubleTag struct {
// contains filtered or unexported fields
}
func NewDoubleTag ¶ added in v0.1.0
func NewDoubleTag(tagName *TagName, payload *DoublePayload) *DoubleTag
type FloatPayload ¶
type FloatPayload float32
func NewFloatPayload ¶ added in v0.1.0
func NewFloatPayload(value float32) *FloatPayload
func (FloatPayload) String ¶ added in v0.2.0
func (p FloatPayload) String() string
func (*FloatPayload) TypeId ¶
func (p *FloatPayload) TypeId() TagType
type FloatTag ¶
type FloatTag struct {
// contains filtered or unexported fields
}
func NewFloatTag ¶ added in v0.1.0
func NewFloatTag(tagName *TagName, payload *FloatPayload) *FloatTag
type IntArrayPayload ¶
type IntArrayPayload []int32
func NewIntArrayPayload ¶ added in v0.1.0
func NewIntArrayPayload(values ...int32) *IntArrayPayload
func (IntArrayPayload) String ¶ added in v0.2.0
func (p IntArrayPayload) String() string
func (*IntArrayPayload) TypeId ¶
func (p *IntArrayPayload) TypeId() TagType
type IntArrayTag ¶
type IntArrayTag struct {
// contains filtered or unexported fields
}
func NewIntArrayTag ¶ added in v0.1.0
func NewIntArrayTag(tagName *TagName, payload *IntArrayPayload) *IntArrayTag
func (*IntArrayTag) Payload ¶ added in v0.1.0
func (t *IntArrayTag) Payload() Payload
func (IntArrayTag) String ¶ added in v0.2.0
func (t IntArrayTag) String() string
func (*IntArrayTag) TagName ¶ added in v0.1.0
func (t *IntArrayTag) TagName() *TagName
func (*IntArrayTag) TypeId ¶
func (t *IntArrayTag) TypeId() TagType
type IntPayload ¶
type IntPayload int32
func NewIntPayload ¶ added in v0.1.0
func NewIntPayload(value int32) *IntPayload
func (IntPayload) String ¶ added in v0.2.0
func (p IntPayload) String() string
func (*IntPayload) TypeId ¶
func (p *IntPayload) TypeId() TagType
type IntTag ¶
type IntTag struct {
// contains filtered or unexported fields
}
func NewIntTag ¶ added in v0.1.0
func NewIntTag(tagName *TagName, payload *IntPayload) *IntTag
type ListPayload ¶
type ListPayload []Payload
func NewListPayload ¶ added in v0.1.0
func NewListPayload(values ...Payload) *ListPayload
func (ListPayload) String ¶ added in v0.2.0
func (p ListPayload) String() string
func (*ListPayload) TypeId ¶
func (p *ListPayload) TypeId() TagType
type ListTag ¶
type ListTag struct {
// contains filtered or unexported fields
}
func NewListTag ¶ added in v0.1.0
func NewListTag(tagName *TagName, payload *ListPayload) *ListTag
type LongArrayPayload ¶
type LongArrayPayload []int64
func NewLongArrayPayload ¶ added in v0.1.0
func NewLongArrayPayload(values ...int64) *LongArrayPayload
func (LongArrayPayload) String ¶ added in v0.2.0
func (p LongArrayPayload) String() string
func (*LongArrayPayload) TypeId ¶
func (p *LongArrayPayload) TypeId() TagType
type LongArrayTag ¶
type LongArrayTag struct {
// contains filtered or unexported fields
}
func NewLongArrayTag ¶ added in v0.1.0
func NewLongArrayTag(tagName *TagName, payload *LongArrayPayload) *LongArrayTag
func (*LongArrayTag) Payload ¶ added in v0.1.0
func (t *LongArrayTag) Payload() Payload
func (LongArrayTag) String ¶ added in v0.2.0
func (t LongArrayTag) String() string
func (*LongArrayTag) TagName ¶ added in v0.1.0
func (t *LongArrayTag) TagName() *TagName
func (*LongArrayTag) TypeId ¶
func (t *LongArrayTag) TypeId() TagType
type LongPayload ¶
type LongPayload int64
func NewLongPayload ¶ added in v0.1.0
func NewLongPayload(value int64) *LongPayload
func (LongPayload) String ¶ added in v0.2.0
func (p LongPayload) String() string
func (*LongPayload) TypeId ¶
func (p *LongPayload) TypeId() TagType
type LongTag ¶
type LongTag struct {
// contains filtered or unexported fields
}
func NewLongTag ¶ added in v0.1.0
func NewLongTag(tagName *TagName, payload *LongPayload) *LongTag
type Payload ¶
type Payload interface { String() string TypeId() TagType // contains filtered or unexported methods }
func NewPayload ¶
type ShortPayload ¶
type ShortPayload int16
func NewShortPayload ¶ added in v0.1.0
func NewShortPayload(value int16) *ShortPayload
func (ShortPayload) String ¶ added in v0.2.0
func (p ShortPayload) String() string
func (*ShortPayload) TypeId ¶
func (p *ShortPayload) TypeId() TagType
type ShortTag ¶
type ShortTag struct {
// contains filtered or unexported fields
}
func NewShortTag ¶ added in v0.1.0
func NewShortTag(tagName *TagName, payload *ShortPayload) *ShortTag
type StringPayload ¶
type StringPayload string
func NewStringPayload ¶ added in v0.1.0
func NewStringPayload(value string) *StringPayload
func (StringPayload) String ¶ added in v0.2.0
func (p StringPayload) String() string
func (*StringPayload) TypeId ¶
func (p *StringPayload) TypeId() TagType
type StringTag ¶
type StringTag struct {
// contains filtered or unexported fields
}
func NewStringTag ¶ added in v0.1.0
func NewStringTag(tagName *TagName, payload *StringPayload) *StringTag
type Tag ¶
type Tag interface { String() string TypeId() TagType TagName() *TagName Payload() Payload // contains filtered or unexported methods }
func Decode ¶
Example ¶
package main import ( "bytes" "fmt" "log" nbt "github.com/Aton-Kish/gonbt" ) func main() { // f, err := os.Open("level.dat") // if err != nil { // log.Fatal(err) // } // defer f.Close() // zr, err := gzip.NewReader(f) // if err != nil { // log.Fatal(err) // } // defer zr.Close() // fake NBT zr := bytes.NewBuffer([]byte{ // CompoundTag(Data): 0x0A, 0x00, 0x04, 0x44, 0x61, 0x74, 0x61, // - IntTag(GameType): 0 0x03, 0x00, 0x08, 0x47, 0x61, 0x6D, 0x65, 0x54, 0x79, 0x70, 0x65, 0x00, 0x00, 0x00, 0x00, // - StringTag(LevelName): "Go NBT" 0x08, 0x00, 0x09, 0x4C, 0x65, 0x76, 0x65, 0x6C, 0x4E, 0x61, 0x6D, 0x65, 0x00, 0x06, 0x47, 0x6F, 0x20, 0x4E, 0x42, 0x54, // - CompoundTag(Version): 0x0A, 0x00, 0x07, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, // - IntTag(Id): 3120 0x03, 0x00, 0x02, 0x49, 0x64, 0x00, 0x00, 0x0C, 0x30, // - StringTag(Name): "1.19.2" 0x08, 0x00, 0x04, 0x4E, 0x61, 0x6D, 0x65, 0x00, 0x06, 0x31, 0x2E, 0x31, 0x39, 0x2E, 0x32, // - StringTag(Series): "main" 0x08, 0x00, 0x06, 0x53, 0x65, 0x72, 0x69, 0x65, 0x73, 0x00, 0x04, 0x6D, 0x61, 0x69, 0x6E, // - ByteTag(Snapshot): 0b 0x01, 0x00, 0x08, 0x53, 0x6E, 0x61, 0x70, 0x73, 0x68, 0x6F, 0x74, 0x00, // - EndTag 0x00, // - EndTag 0x00, }) dat, err := nbt.Decode(zr) if err != nil { log.Fatal(err) } fmt.Println(nbt.PrettyStringify(dat, " ")) }
Output: { Data: { GameType: 0, LevelName: "Go NBT", Version: { Id: 3120, Name: "1.19.2", Series: "main", Snapshot: 0b } } }
func Parse ¶
Example ¶
package main import ( "fmt" "log" nbt "github.com/Aton-Kish/gonbt" ) func main() { str := `{Data: {GameType: 0, LevelName: "Go NBT", Version: {Id: 3120, Name: "1.19.2", Series: "main", Snapshot: 0b}}}` dat, err := nbt.Parse(str) if err != nil { log.Fatal(err) } fmt.Println(nbt.Stringify(dat)) }
Output: {Data: {GameType: 0, LevelName: "Go NBT", Version: {Id: 3120, Name: "1.19.2", Series: "main", Snapshot: 0b}}}
Source Files ¶
- errors.go
- logger.go
- name.go
- payload.go
- payload_byte.go
- payload_byte_array.go
- payload_compound.go
- payload_double.go
- payload_float.go
- payload_int.go
- payload_int_array.go
- payload_list.go
- payload_long.go
- payload_long_array.go
- payload_short.go
- payload_string.go
- tag.go
- tag_byte.go
- tag_byte_array.go
- tag_compound.go
- tag_double.go
- tag_end.go
- tag_float.go
- tag_int.go
- tag_int_array.go
- tag_list.go
- tag_long.go
- tag_long_array.go
- tag_short.go
- tag_string.go
- type.go
Click to show internal directories.
Click to hide internal directories.